public void WriteEntryAssign2() { uint id = 1; uint seq = 1; EntryFlags flags = EntryFlags.Persistent; string name = "Testing"; Value val = Value.MakeDouble(5); Message msg = Message.EntryAssign(name, id, seq, val, flags); WireEncoder enc = new WireEncoder(0x0200); msg.Write(enc); byte[] buf = enc.Buffer; WireDecoder dec = new WireDecoder(new MemoryStream(buf), 0x0200); byte u8 = 0; NtType type = 0; string str = ""; ushort u16 = 0; Assert.That(dec.Read8(ref u8), Is.True); Assert.That(u8, Is.EqualTo((byte)EntryAssign)); Assert.That(dec.ReadString(ref str), Is.True); Assert.That(str, Is.EqualTo(name)); Assert.That(dec.ReadType(ref type), Is.True); Assert.That(type, Is.EqualTo(NtType.Double)); Assert.That(dec.Read16(ref u16), Is.True); Assert.That(u16, Is.EqualTo(id)); Assert.That(dec.Read16(ref u16), Is.True); Assert.That(u16, Is.EqualTo(seq)); val = dec.ReadValue(type); Assert.That(val, Is.Not.Null); Assert.That(val.Type, Is.EqualTo(NtType.Double)); Assert.That(val.GetDouble(), Is.EqualTo(5)); }
internal static void SetEntryFlags(string name, EntryFlags flags) { UIntPtr size; IntPtr str = CreateCachedUTF8String(name, out size); Interop.NT_SetEntryFlags(str, size, (uint)flags); }
internal EntryInfo(string name, NtType type, EntryFlags flags, long lastChange) { Name = name; Type = type; Flags = flags; LastChange = lastChange; }
/// <summary> /// Sets flags associated with an entry /// </summary> /// <param name="name">The entry name</param> /// <param name="flags">The bitmask of the flags to set</param> public static void SetEntryFlags(string name, EntryFlags flags) { #if CORE CoreMethods.SetEntryFlags(name, flags); #else Storage.Instance.SetEntryFlags(name, flags); #endif }
public void Update(int pageFirst, int pageLast, int rawLength, int compressedLength, EntryFlags flags) { FirstPage = pageFirst; LastPage = pageLast; Length = rawLength; CompressedLength = compressedLength; Modified = DateTime.UtcNow; Flags = flags; }
/// <summary> /// Read ctor /// </summary> protected EntryInstance(Type parent, ResReader reader) { this.parent = parent; // header var size = reader.ReadUInt16(); flags = (EntryFlags) reader.ReadUInt16(); key = StringPoolRef.Read(reader, parent.TypeSpec.Package.KeyStrings); }
/// <summary> /// Read ctor /// </summary> protected EntryInstance(Type parent, ResReader reader) { this.parent = parent; // header var size = reader.ReadUInt16(); flags = (EntryFlags)reader.ReadUInt16(); key = StringPoolRef.Read(reader, parent.TypeSpec.Package.KeyStrings); }
public static Message FlagsUpdate(uint id, EntryFlags flags) { var msg = new Message(MsgType.FlagsUpdate) { Id = id, Flags = (uint)flags }; return(msg); }
private void SetFlagValue(EntryFlags mask, bool value) { if (value) { this.flags |= mask; } else { this.flags &= ~mask; } }
/// <summary> /// Adds an entry. Delta is assumed to be delta_description_t. Should only need to be called when parsing svc_deltadescription. /// </summary> /// <param name="delta"></param> public void AddEntry(HalfLifeDelta delta) { String name = (String)delta.FindEntryValue("name"); UInt32 nBits = (UInt32)delta.FindEntryValue("nBits"); Single divisor = (Single)delta.FindEntryValue("divisor"); EntryFlags flags = (EntryFlags)((UInt32)delta.FindEntryValue("flags")); //Single preMultiplier = (Single)delta.FindEntryValue("preMultiplier"); AddEntry(name, nBits, divisor, flags); }
/// <summary> /// Adds an entry manually. Should only need to be called when creating a delta_description_t structure. /// </summary> /// <param name="name"></param> /// <param name="nBits"></param> /// <param name="divisor"></param> /// <param name="flags"></param> public void AddEntry(String name, UInt32 nBits, Single divisor, EntryFlags flags) { Entry entry = new Entry(); entry.Name = name; entry.nBits = nBits; entry.Divisor = divisor; entry.Flags = flags; entry.PreMultiplier = 1.0f; entryList.Add(entry); }
public bool Spawn(int index, out EntryFlags flags) { if (index >= 0 && index < m_Entries.Count) { return(Spawn(m_Entries[index], out flags)); } else { flags = EntryFlags.InvalidEntry; return(false); } }
public void WriteFlagsUpdate2() { //Flags not supported in 2 uint id = 1; EntryFlags flags = EntryFlags.Persistent; Message msg = Message.FlagsUpdate(id, flags); WireEncoder enc = new WireEncoder(0x0200); msg.Write(enc); byte[] buf = enc.Buffer; Assert.That(buf, Has.Length.EqualTo(0)); }
public void TestEntryInfo() { string name = "TestEntryInfo"; NtType type = NtType.Boolean; EntryFlags flags = EntryFlags.Persistent; long lastChange = 55; EntryInfo info = new EntryInfo(name, type, flags, lastChange); Assert.That(info.Name, Is.EqualTo(name)); Assert.That(info.Type, Is.EqualTo(type)); Assert.That(info.Flags, Is.EqualTo(flags)); Assert.That(info.LastChange, Is.EqualTo(lastChange)); }
public void CreateFlagsUpdate() { EntryFlags flags = EntryFlags.Persistent; uint id = 1; Message msg = Message.FlagsUpdate(id, flags); Assert.That(msg.Type, Is.EqualTo(FlagsUpdate)); Assert.That(msg.Id, Is.EqualTo(id)); Assert.That(msg.Flags, Is.EqualTo((uint)flags)); Assert.That(msg.SeqNumUid, Is.EqualTo(0)); Assert.That(msg.Str, Is.EqualTo("")); Assert.That(msg.Val, Is.Not.Null); Assert.That(msg.Val.Type, Is.EqualTo(NtType.Unassigned)); }
public void SetEntryFlags(string name, EntryFlags flags) { if (string.IsNullOrEmpty(name)) { return; } IDisposable monitor = null; try { monitor = m_monitor.Enter(); Entry entry; if (!m_entries.TryGetValue(name, out entry)) { //Key does not exist. Return return; } if (entry.Flags == flags) { return; } if ((entry.Flags & EntryFlags.Persistent) != (flags & EntryFlags.Persistent)) { m_persistentDirty = true; } entry.Flags = flags; m_notifier.NotifyEntry(name, entry.Value, NotifyFlags.NotifyFlagsChanged | NotifyFlags.NotifyLocal); if (m_queueOutgoing == null) { return; } var queueOutgoing = m_queueOutgoing; uint id = entry.Id; if (id != 0xffff) { IDisposable monitorToUnlock = Interlocked.Exchange(ref monitor, null); monitorToUnlock.Dispose(); queueOutgoing(Message.FlagsUpdate(id, flags), null, null); } } finally { monitor?.Dispose(); } }
public void TestGetEntryFlags() { string key = "testKey"; CoreMethods.SetEntryString(key, "value"); EntryFlags flags = CoreMethods.GetEntryFlags(key); Assert.That(flags, Is.EqualTo(EntryFlags.None)); CoreMethods.SetEntryFlags(key, EntryFlags.Persistent); flags = CoreMethods.GetEntryFlags(key); Assert.That(flags, Is.EqualTo(EntryFlags.Persistent)); }
public void TestGetEntryFlags() { string key = "testKey"; NtCore.SetEntryValue(key, Value.MakeString("value")); EntryFlags flags = NtCore.GetEntryFlags(key); Assert.That(flags, Is.EqualTo(EntryFlags.None)); NtCore.SetEntryFlags(key, EntryFlags.Persistent); flags = NtCore.GetEntryFlags(key); Assert.That(flags, Is.EqualTo(EntryFlags.Persistent)); }
public void CreateEntryAssign() { uint id = 1; uint seq = 1; EntryFlags flags = EntryFlags.Persistent; string name = "Testing"; Value val = Value.MakeDouble(5); Message msg = Message.EntryAssign(name, id, seq, val, flags); Assert.That(msg.Type, Is.EqualTo(EntryAssign)); Assert.That(msg.Id, Is.EqualTo(id)); Assert.That(msg.Flags, Is.EqualTo((uint)flags)); Assert.That(msg.SeqNumUid, Is.EqualTo(seq)); Assert.That(msg.Str, Is.EqualTo(name)); Assert.That(msg.Val, Is.Not.Null); Assert.That(msg.Val.IsDouble()); Assert.That(msg.Val.GetDouble(), Is.EqualTo(5)); }
public void WriteFlagsUpdate3() { uint id = 1; EntryFlags flags = EntryFlags.Persistent; Message msg = Message.FlagsUpdate(id, flags); WireEncoder enc = new WireEncoder(0x0300); msg.Write(enc); byte[] buf = enc.Buffer; WireDecoder dec = new WireDecoder(new MemoryStream(buf), 0x0300); byte u8 = 0; ushort u16 = 0; Assert.That(dec.Read8(ref u8), Is.True); Assert.That(u8, Is.EqualTo((byte)FlagsUpdate)); Assert.That(dec.Read16(ref u16), Is.True); Assert.That(u16, Is.EqualTo(id)); Assert.That(dec.Read8(ref u8), Is.True); Assert.That(u8, Is.EqualTo((byte)flags)); }
protected override bool CreateChildren(bool diffOldChildren = false) { try { if (_mergedDescriptor.PropertyType.IsValueType || EntryFlags.HasFlag(Flags.Immutable)) { return(base.CreateChildren(diffOldChildren)); } ChildCollection.Clear(); var mergedProperties = MultiSelectRootGridEntry.PropertyMerger.GetMergedProperties( _mergedDescriptor.GetValues(_objects), this, _propertySort, OwnerTab); Debug.WriteLineIf( CompModSwitches.DebugGridView.TraceVerbose && mergedProperties is null, "PropertyGridView: MergedProps returned null!"); if (mergedProperties is not null) { ChildCollection.AddRange(mergedProperties); } bool expandable = Children.Count > 0; if (!expandable) { SetFlag(Flags.ExpandableFailed, true); } return(expandable); } catch (Exception e) { Debug.Fail(e.Message); return(false); } }
// Add new catalog entry to proper scope // Risky: caller may not know where it went; maybe merge Global & Persistent? internal void AddEntry(string name, DataType datatype, EntryKinds kind, EntryFlags flags = EntryFlags.None, TypedValue value = null) { var scope = (flags.HasFlag(EntryFlags.Persistent)) ? _catalog.PersistentVars : this; var entry = new CatalogEntry { Name = name, DataType = datatype, Kind = kind, Flags = flags, Scope = scope, Value = value, }; scope.Add(entry); // update catalog if (flags.HasFlag(EntryFlags.Persistent) && _catalog.SaveFlag) { Logger.Assert(entry.Kind == EntryKinds.Type || entry.Value == null, entry); if (entry.Kind == EntryKinds.Type) { _catalog.StoreEntry(entry); } } }
// Add a new entry to the catalog. // Do kind, flags and other stuff here public void AddNewEntry(string name, DataType datatype, EntryKinds kind, EntryFlags flags) { if (_catalog.IsPersist(name)) { flags |= EntryFlags.Persistent; } if (kind == EntryKinds.Value && datatype is DataTypeRelation && _catalog.IsDatabase(name)) { flags |= EntryFlags.Database; } AddEntry(name, datatype, kind, flags, null); // preliminary entry, value can only be set by code //AddEntry(name, datatype, kind, flags, datatype.DefaultValue()); // make sure it has something, to avoid later errrors if (kind == EntryKinds.Value) { if (datatype is DataTypeRelation) { (datatype as DataTypeRelation).ProposeCleanName(name); } else if (datatype is DataTypeTuple) { (datatype as DataTypeTuple).ProposeCleanName(name); } } }
public SpawnerGump(Spawner spawner, SpawnerEntry focusentry, int page) : base(50, 50) { m_Spawner = spawner; m_Entry = focusentry; m_Page = page; AddPage(0); AddBackground(0, 0, 343, 371 + (m_Entry != null ? 44 : 0), 5054); AddHtml(95, 1, 250, 20, "<BASEFONT COLOR=#F4F4F4>Creatures List</BASEFONT>", false, false); AddHtml(245, 1, 250, 20, "<BASEFONT COLOR=#F4F4F4>#</BASEFONT>", false, false); AddHtml(282, 1, 250, 20, "<BASEFONT COLOR=#F4F4F4>Prb</BASEFONT>", false, false); //AddLabel( 95, 1, 0, "Creatures List" ); int offset = 0; for (int i = 0; i < 13; i++) { int textindex = i * 5; int entryindex = (m_Page * 13) + i; SpawnerEntry entry = null; if (entryindex < spawner.Entries.Count) { entry = m_Spawner.Entries[entryindex]; } if (entry == null || m_Entry != entry) { AddButton(5, (22 * i) + 21 + offset, entry != null ? 0xFBA : 0xFA5, entry != null ? 0xFBC : 0xFA7, GetButtonID(2, (i * 2)), GumpButtonType.Reply, 0); //Expand } else { AddButton(5, (22 * i) + 21 + offset, entry != null ? 0xFBB : 0xFA5, entry != null ? 0xFBC : 0xFA7, GetButtonID(2, (i * 2)), GumpButtonType.Reply, 0); //Unexpand } AddButton(38, (22 * i) + 21 + offset, 0xFA2, 0xFA4, GetButtonID(2, 1 + (i * 2)), GumpButtonType.Reply, 0); //Delete AddImageTiled(71, (22 * i) + 20 + offset, 161, 23, 0xA40); //creature text box AddImageTiled(72, (22 * i) + 21 + offset, 159, 21, 0xBBC); //creature text box AddImageTiled(235, (22 * i) + 20 + offset, 35, 23, 0xA40); //maxcount text box AddImageTiled(236, (22 * i) + 21 + offset, 33, 21, 0xBBC); //maxcount text box AddImageTiled(273, (22 * i) + 20 + offset, 35, 23, 0xA40); //probability text box AddImageTiled(274, (22 * i) + 21 + offset, 33, 21, 0xBBC); //probability text box string name = ""; string probability = ""; string maxcount = ""; EntryFlags flags = EntryFlags.None; if (entry != null) { name = (string)entry.SpawnedName; probability = entry.SpawnedProbability.ToString(); maxcount = entry.SpawnedMaxCount.ToString(); flags = entry.Valid; AddLabel(315, (22 * i) + 20 + offset, 0, spawner.CountSpawns(entry).ToString()); } AddTextEntry(75, (22 * i) + 21 + offset, 156, 21, ((flags & EntryFlags.InvalidType) != 0) ? 33 : 0, textindex, name); //creature AddTextEntry(239, (22 * i) + 21 + offset, 30, 21, 0, textindex + 1, maxcount); //max count AddTextEntry(277, (22 * i) + 21 + offset, 30, 21, 0, textindex + 2, probability); //probability if (entry != null && m_Entry == entry) { AddLabel(5, (22 * i) + 42, 0x384, "Params"); AddImageTiled(55, (22 * i) + 42, 253, 23, 0xA40); //Parameters AddImageTiled(56, (22 * i) + 43, 251, 21, 0xBBC); //Parameters AddLabel(5, (22 * i) + 64, 0x384, "Props"); AddImageTiled(55, (22 * i) + 64, 253, 23, 0xA40); //Properties AddImageTiled(56, (22 * i) + 65, 251, 21, 0xBBC); //Properties AddTextEntry(59, (22 * i) + 42, 248, 21, ((flags & EntryFlags.InvalidParams) != 0) ? 33 : 0, textindex + 3, entry.Parameters); //parameters AddTextEntry(59, (22 * i) + 62, 248, 21, ((flags & EntryFlags.InvalidProps) != 0) ? 33 : 0, textindex + 4, entry.Properties); //properties offset += 44; } } AddButton(5, 347 + offset, 0xFB1, 0xFB3, 0, GumpButtonType.Reply, 0); AddLabel(38, 347 + offset, 0x384, "Cancel"); AddButton(5, 325 + offset, 0xFB7, 0xFB9, GetButtonID(1, 2), GumpButtonType.Reply, 0); AddLabel(38, 325 + offset, 0x384, "Okay"); AddButton(110, 325 + offset, 0xFB4, 0xFB6, GetButtonID(1, 3), GumpButtonType.Reply, 0); AddLabel(143, 325 + offset, 0x384, "Bring to Home"); AddButton(110, 347 + offset, 0xFA8, 0xFAA, GetButtonID(1, 4), GumpButtonType.Reply, 0); AddLabel(143, 347 + offset, 0x384, "Total Respawn"); AddButton(253, 325 + offset, 0xFB7, 0xFB9, GetButtonID(1, 5), GumpButtonType.Reply, 0); AddLabel(286, 325 + offset, 0x384, "Apply"); if (m_Page > 0) { AddButton(276, 308 + offset, 0x15E3, 0x15E7, GetButtonID(1, 0), GumpButtonType.Reply, 0); } else { AddImage(276, 308 + offset, 0x25EA); } if ((m_Page + 1) * 13 <= m_Spawner.Entries.Count) { AddButton(293, 308 + offset, 0x15E1, 0x15E5, GetButtonID(1, 1), GumpButtonType.Reply, 0); } else { AddImage(293, 308 + offset, 0x25E6); } }
/// <summary> /// Clears flags on the specified key in this table. /// </summary> /// <param name="key">The key name.</param> /// <param name="flags">The flags to clear. (Bitmask)</param> public void ClearFlags(string key, EntryFlags flags) { m_ntCore.SetEntryFlags(m_path + PathSeperatorChar + key, GetFlags(key) & ~flags); }
public bool Spawn( SpawnerEntry entry, out EntryFlags flags ) { Map map = Map; flags = EntryFlags.None; if ( map == null || map == Map.Internal || Parent != null ) return false; //Defrag taken care of in Spawn(), beforehand //Count check taken care of in Spawn(), beforehand Type type = SpawnerType.GetType( entry.CreaturesName ); if ( type != null ) { try { object o = null; string[] paramargs; string[] propargs; if ( String.IsNullOrEmpty( entry.Properties ) ) propargs = new string[0]; else propargs = CommandSystem.Split( entry.Properties.Trim() ); string[,] props = FormatProperties( propargs ); PropertyInfo[] realProps = GetTypeProperties( type, props ); if ( realProps == null ) { flags = EntryFlags.InvalidProps; return false; } if ( String.IsNullOrEmpty( entry.Parameters ) ) paramargs = new string[0]; else paramargs = entry.Parameters.Trim().Split( ' ' ); ConstructorInfo[] ctors = type.GetConstructors(); for ( int i = 0; i < ctors.Length; ++i ) { ConstructorInfo ctor = ctors[i]; if ( Add.IsConstructable( ctor, AccessLevel.GameMaster ) ) { ParameterInfo[] paramList = ctor.GetParameters(); if ( paramargs.Length == paramList.Length ) { object[] paramValues = Add.ParseValues( paramList, paramargs ); if ( paramValues != null ) { o = ctor.Invoke( paramValues ); for ( int j = 0; j < realProps.Length; j++ ) { if ( realProps[j] != null ) { object toSet = null; string result = Properties.ConstructFromString( realProps[j].PropertyType, o, props[j, 1], ref toSet ); if ( result == null ) realProps[j].SetValue( o, toSet, null ); else { flags = EntryFlags.InvalidProps; if ( o is IEntity ) ((IEntity)o).Delete(); return false; } } } break; } } } } if ( o is Mobile ) { Mobile m = (Mobile)o; m_Creatures.Add( m, entry ); entry.Creatures.Add( m ); Point3D loc = ( m is BaseVendor ? this.Location : GetSpawnPosition() ); m.OnBeforeSpawn( loc, map ); InvalidateProperties(); m.MoveToWorld( loc, map ); if ( m is BaseCreature ) { BaseCreature c = (BaseCreature)m; if( m_WalkingRange >= 0 ) c.RangeHome = m_WalkingRange; else c.RangeHome = m_HomeRange; c.CurrentWayPoint = m_WayPoint; if ( m_Team > 0 ) c.Team = m_Team; c.Home = this.Location; //c.Spawner = (ISpawner)this; } m.Spawner = this; m.OnAfterSpawn(); } else if ( o is Item ) { Item item = (Item)o; m_Creatures.Add( item, entry ); entry.Creatures.Add( item ); Point3D loc = GetSpawnPosition(); item.OnBeforeSpawn( loc, map ); item.MoveToWorld( loc, map ); item.Spawner = this; item.OnAfterSpawn(); } else { flags = EntryFlags.InvalidType | EntryFlags.InvalidParams; return false; } } catch ( Exception e ) { Console.WriteLine( "EXCEPTION CAUGHT: {0:X}", Serial ); Console.WriteLine( e ); return false; } InvalidateProperties(); //If its anywhere before finishing the spawning process, DEFRAG will nuke the entry. return true; } flags = EntryFlags.InvalidType; return false; }
public bool Spawn( int index, out EntryFlags flags ) { if ( index >= 0 && index < m_Entries.Count ) return Spawn( m_Entries[index], out flags ); else { flags = EntryFlags.InvalidEntry; return false; } }
public void SetFlags(string key, EntryFlags flags) { }
private bool GetFlagValue(EntryFlags mask) { return((this.flags & mask) != 0); }
internal PagedContainerEntry(string name, int pageFirst, int pageLast, int rawLength, int compressedLength, EntryFlags flags, DateTime modified) { Name = name; Update(pageFirst, pageLast, rawLength, compressedLength, flags); Modified = modified; }
/// <inheritdoc cref="NtCore.SetEntryFlags"/> public void SetEntryFlags(string name, EntryFlags flags) { m_storage.SetEntryFlags(name, flags); }
public void ClearFlags(string key, EntryFlags flags) { }
/// <summary> /// Sets flags on the specified key in this table. /// </summary> /// <param name="key">The key name.</param> /// <param name="flags">The flags to set. (Bitmask)</param> public void SetFlags(string key, EntryFlags flags) { CoreMethods.SetEntryFlags(m_path + PathSeperatorChar + key, GetFlags(key) | flags); }
public static bool Any(this EntryFlags f, EntryFlags checkFlags) => (f & checkFlags) > 0;
private void ToggleFlag(EntryFlags flag) { _flags ^= flag; }
internal static void SetEntryFlags(string name, EntryFlags flags) { UIntPtr size; byte[] str = CreateUTF8String(name, out size); Interop.NT_SetEntryFlags(str, size, (uint)flags); }
/// <summary> /// Create ctor /// </summary> protected EntryInstance(Type parent, EntryFlags flags, string key) { this.parent = parent; this.flags = flags; this.key = key; }
/// <summary>Gets the value for a masked item.</summary> /// <param name="mask">Mask value.</param> /// <returns>true if the flag is set; false otherwise.</returns> private bool GetFlagValue(EntryFlags mask) { return (this.flags & mask) != 0; }
internal static EntryInfo[] GetEntries(string prefix, EntryFlags types) { UIntPtr size; byte[] str = CreateUTF8String(prefix, out size); UIntPtr arrSize = UIntPtr.Zero; IntPtr arr = Interop.NT_GetEntryInfo(str, size, (uint)types, ref arrSize); int entryInfoSize = Marshal.SizeOf(typeof(NtEntryInfo)); int arraySize = (int)arrSize.ToUInt64(); EntryInfo[] entryArray = new EntryInfo[arraySize]; for (int i = 0; i < arraySize; i++) { IntPtr data = new IntPtr(arr.ToInt64() + entryInfoSize * i); NtEntryInfo info = (NtEntryInfo)Marshal.PtrToStructure(data, typeof(NtEntryInfo)); entryArray[i] = new EntryInfo(info.name.ToString(), info.type, (EntryFlags)info.flags, (long)info.last_change); } Interop.NT_DisposeEntryInfoArray(arr, arrSize); return entryArray; }
public HashSet<string> GetKeys(EntryFlags types) { return null; }
public static bool Has(this EntryFlags f, EntryFlags checkFlags) => (f & checkFlags) == checkFlags;
/// <summary> /// Gets a set of all the keys contained in the table with the specified type. /// </summary> /// <param name="types">Bitmask of types to check for; 0 is treated as a "don't care".</param> /// <returns>A set of all keys currently in the table.</returns> public HashSet<string> GetKeys(EntryFlags types) { HashSet<string> keys = new HashSet<string>(); int prefixLen = m_path.Length + 1; foreach (EntryInfo entry in CoreMethods.GetEntries(m_path + PathSeperatorChar, types)) { string relativeKey = entry.Name.Substring(prefixLen); if (relativeKey.IndexOf(PathSeperatorChar) != -1) continue; keys.Add(relativeKey); } return keys; }