/// <summary> /// Delete all data from the Package that is not contained in the list of paths to keep /// </summary> /// <param name="packagePath">Path to the Package</param> /// <param name="storagePathsToKeep">List of relative paths of data in the package that should be kept</param> public async Task ScrubStorageAsync(string packagePath, List <string> storagePathsToKeep) { var package = await RetrievePackageAsync(packagePath); var semaphore = LockingDictionary.GetOrAdd(packagePath, new SemaphoreSlim(1)); try { await semaphore.WaitAsync(); var parts = package.Entries.ToList(); var totalEntries = parts.Count; var progress = 0; foreach (var part in parts) { if (!storagePathsToKeep.Contains(part.FullName)) { part.Delete(); } progress++; ScrubProgress?.Invoke(this, new ScrubProgressArgs(packagePath, totalEntries, progress)); } AutoFlushPackage(packagePath); } finally { semaphore.Release(); } }
public UserCommandMessage(LockingDictionary<uint, string> StringResources, MessageDirection Direction, byte[] Buffer, int StartIndex = 0) : base() { this.TransferDirection = Direction; this.StringResources = StringResources; ReadFrom(Buffer, StartIndex); }
private LockingDictionary <StorageKey, ObjectDecorator> GetSingleKeySpace(DataBuffer keySpace) { var hash = keySpace.GetHashCode(); LockingDictionary <StorageKey, ObjectDecorator> keySpaceDct; // upgradeable blocks other upgradeable, so try read first using (_keySpaces.Lock(LockType.Read)) { if (_keySpaces.TryGetValue(hash, out keySpaceDct)) { return(keySpaceDct); } } // didn't find it, so now try upgradeable to write if need be using (_keySpaces.Lock(LockType.ReadUpgradable)) { if (!_keySpaces.TryGetValue(hash, out keySpaceDct)) { using (_keySpaces.Lock(LockType.Write)) { keySpaceDct = new LockingDictionary <StorageKey, ObjectDecorator>(); _keySpaces.Add(hash, keySpaceDct); } } return(keySpaceDct); } }
public LockSpec(LockType type, LockingDictionary <TKey, TValue> dictionary) { Type = type; _dictionary = dictionary; _previous = _lastLock; _lastLock = this; }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string res_name; StringResources.TryGetValue(resourceID, out res_name); if (RaiseChangedEvent) { if (res_name != null) { ResourceName = res_name.Replace(FileExtensions.MID, FileExtensions.MP3); } else { ResourceName = String.Empty; } } else { if (res_name != null) { resourceName = res_name.Replace(FileExtensions.MID, FileExtensions.MP3); } else { resourceName = String.Empty; } } }
public virtual void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string res_name; StringResources.TryGetValue(headlineResourceID, out res_name); if (RaiseChangedEvent) { if (res_name != null) { Headline = res_name; } else { Headline = String.Empty; } } else { if (res_name != null) { headline = res_name; } else { headline = String.Empty; } } }
public override void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { base.ResolveStrings(StringResources, RaiseChangedEvent); string res_icon; StringResources.TryGetValue(resourceIconID, out res_icon); if (RaiseChangedEvent) { if (res_icon != null) { ResourceIconName = res_icon; } else { ResourceIconName = String.Empty; } } else { if (res_icon != null) { resourceIconName = res_icon; } else { resourceIconName = String.Empty; } } }
/// <summary> /// Store a data stream inside the Pacakge. /// If the data already exists in the Package it will be overwritten. /// </summary> /// <param name="packagePath">Path to the Package</param> /// <param name="data">The stream that should be stored in the Package</param> /// <param name="storagePath">The relative path where the data should be stored inside the Package</param> public async Task AddItemToPackageAsync(string packagePath, Stream data, string storagePath) { var package = await RetrievePackageAsync(packagePath); var semaphore = LockingDictionary.GetOrAdd(packagePath, new SemaphoreSlim(1)); try { await semaphore.WaitAsync(); var part = package.Entries.Any(x => x.FullName == storagePath) ? package.GetEntry(storagePath) : package.CreateEntry(storagePath); using (var partStream = part.Open()) { await data.CopyToAsync(partStream); } AutoFlushPackage(packagePath); } finally { semaphore.Release(); } }
/// <summary> /// Retrieves data from the Package. /// </summary> /// <param name="packagePath">Path to the Package</param> /// <param name="storagePath">The relative path where data is stored inside the Package</param> /// <exception cref="KeyNotFoundException">Thrown if the storagePath could not be found in the package</exception> /// <returns>MemoryStream containing the data from the Package</returns> public async Task <Stream> RetrieveDataFromPackageAsync(string packagePath, string storagePath) { var package = await RetrievePackageAsync(packagePath); var semaphore = LockingDictionary.GetOrAdd(packagePath, new SemaphoreSlim(1)); try { await semaphore.WaitAsync(); if (package.Entries.All(x => x.FullName != storagePath)) { throw new KeyNotFoundException($"The path {storagePath} could not be found in the Package"); } var part = package.GetEntry(storagePath); var returnStream = new MemoryStream(); using (var partStream = part.Open()) { await partStream.CopyToAsync(returnStream); returnStream.Position = 0; } return(returnStream); } finally { semaphore.Release(); } }
/// <summary> /// Retrieve a Package for usage. This method will create the Package if it does not exist yet or open it if it exists /// </summary> /// <param name="packagePath">Path to the Package to initialize</param> private async Task <ZipArchive> RetrievePackageAsync(string packagePath) { var semaphore = LockingDictionary.GetOrAdd(packagePath, new SemaphoreSlim(1)); try { await semaphore.WaitAsync(); if (PackageDictionary.ContainsKey(packagePath)) { return(PackageDictionary[packagePath]); } if (!File.Exists(packagePath)) { var createdZip = new ZipArchive(File.Open(packagePath, FileMode.OpenOrCreate), ZipArchiveMode.Create); createdZip.Dispose(); } var tmpPackage = new ZipArchive(File.Open(packagePath, FileMode.OpenOrCreate), ZipArchiveMode.Update); PackageDictionary.Add(packagePath, tmpPackage); return(tmpPackage); } finally { semaphore.Release(); } }
/// <summary> /// Constructor. /// </summary> /// <param name="StringResources">The StringResources to use.</param> public ServerConnection(LockingDictionary <uint, string> StringResources) { // init the queues (receive, send, logs, exceptions) ReceiveQueue = new LockingQueue <GameMessage>(); SendQueue = new LockingQueue <GameMessage>(); ExceptionQueue = new LockingQueue <Exception>(); // the debugqueue to give back sent packets (with crc/...) if activated OutgoingPacketLog = new LockingQueue <GameMessage>(); // save reference to string dictionary stringResources = StringResources; // setup the packetcontroller messageController = new MessageControllerClient(StringResources); // hook up listeners messageController.MessageAvailable += new GameMessageEventHandler(OnMessageControllerNewMessageAvailable); messageController.ServerSaveChanged += new ServerSaveChangedEventHandler(OnMessageControllerNewServerSave); messageController.HandlerError += new HandlerErrorEventHandler(OnMessageControllerHandlerError); messageController.ProtocolModeChanged += new EventHandler(OnMessageControllerProtocolModeChanged); // setup the ping timer timPing = new System.Timers.Timer(); timPing.Enabled = false; timPing.Interval = PINGINTERVAL; timPing.Elapsed += new ElapsedEventHandler(OnPingTimerElapsed); }
public UserCommandMessage(LockingDictionary <uint, string> StringResources, MessageDirection Direction, byte[] Buffer, int StartIndex = 0) : base() { this.TransferDirection = Direction; this.StringResources = StringResources; ReadFrom(Buffer, StartIndex); }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string res_mainoverlayname; StringResources.TryGetValue(overlayFileRID, out res_mainoverlayname); if (RaiseChangedEvent) { if (res_mainoverlayname != null) { OverlayFile = res_mainoverlayname; } else { OverlayFile = String.Empty; } } else { if (res_mainoverlayname != null) { overlayFile = res_mainoverlayname; } else { overlayFile = String.Empty; } } }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string res_name; string res_mainoverlayname; StringResources.TryGetValue(nameRID, out res_name); StringResources.TryGetValue(overlayFileRID, out res_mainoverlayname); if (RaiseChangedEvent) { if (res_name != null) { Name = res_name; } else { Name = String.Empty; } if (res_mainoverlayname != null) { OverlayFile = res_mainoverlayname; } else { OverlayFile = String.Empty; } } else { if (res_name != null) { name = res_name; } else { name = String.Empty; } if (res_mainoverlayname != null) { overlayFile = res_mainoverlayname; } else { overlayFile = String.Empty; } } foreach (SubOverlay obj in subOverlays) { obj.ResolveStrings(StringResources, RaiseChangedEvent); } foreach (SubOverlay obj in motionSubOverlays) { obj.ResolveStrings(StringResources, RaiseChangedEvent); } }
/// <summary> /// Constructor /// </summary> /// <param name="StringResources">A dictionary to resolve Meridian59 strings from.</param> public MessageController(LockingDictionary<uint, string> StringResources) { // save string dictionary this.stringResources = StringResources; // reset Reset(); }
/// <summary> /// Constructor /// </summary> /// <param name="StringResources">A threadsafe dictionary used to resolve Meridian Strings from.</param> public PIDecoder(LockingDictionary<uint, string> StringResources) { this.stringResources = StringResources; if (StringResources == null) stringBytes = Encoding.Default.GetBytes(FALLBACKSTRING); Reset(); }
public void TestLockedSet() { var ld = new LockingDictionary <int, string>().Locked; Assert.ThrowsException <NotSupportedException>(() => ld[0] = "zero"); Assert.ThrowsException <NotSupportedException>(() => ld.Add(0, "zero")); Assert.ThrowsException <NotSupportedException>(() => ld.Clear()); Assert.ThrowsException <NotSupportedException>(() => ld.Remove(1)); }
/// <summary> /// Constructor /// </summary> /// <param name="StringResources">A threadsafe dictionary used to resolve Meridian Strings from.</param> public PIEncoder(LockingDictionary <uint, string> StringResources) { this.stringResources = StringResources; if (StringResources == null) { hashString = Encoding.Default.GetBytes(StaticFallbackHashString); } Reset(); }
public void TestLockedGet() { var ld = new LockingDictionary <int, string> { [1] = "one", [2] = "two" }; ld.Add(10, "ten"); _TestDictionary(ld.Locked); }
/// <summary> /// Constructor /// </summary> /// <param name="StringResources">A threadsafe dictionary used to resolve Meridian Strings from.</param> public PIDecoder(LockingDictionary <uint, string> StringResources) { this.stringResources = StringResources; if (StringResources == null) { stringBytes = Encoding.Default.GetBytes(FALLBACKSTRING); } Reset(); }
public unsafe ChatMessage( ChatMessageType MessageType, LockingDictionary <uint, string> StringResources, ref byte *Buffer) { this.chatMessageType = MessageType; this.stringResources = StringResources; Variables = new List <InlineVariable>(); Styles = new List <ChatStyle>(); ReadFrom(ref Buffer); }
public ChatMessage( ChatMessageType MessageType, LockingDictionary <uint, string> StringResources, byte[] Buffer, int StartIndex = 0) { this.chatMessageType = MessageType; this.stringResources = StringResources; Variables = new List <InlineVariable>(); Styles = new List <ChatStyle>(); ReadFrom(Buffer, StartIndex); }
public void TestParentReferenceStability() { var ld = new LockingDictionary <int, string> { [1] = "one", [2] = "two" }; var locked = ld.Locked; ld[2] = "Two!"; ld.Add(4, "Four?"); Assert.IsTrue(locked.ContainsKey(4)); Assert.AreEqual("Two!", ld[2]); }
public ChatMessage( ChatMessageType MessageType, LockingDictionary<uint, string> StringResources, uint ResourceID, List<InlineVariable> Variables, List<ChatStyle> Styles) { this.chatMessageType = MessageType; this.stringResources = StringResources; this.Variables = Variables; this.Styles = Styles; this.resourceID = ResourceID; }
public ObjectChatMessage( uint SourceObjectID, uint SourceResourceID, ChatTransmissionType TransmissionType, LockingDictionary<uint, string> LookupList, uint ResourceID, List<InlineVariable> Variables, List<ChatStyle> Styles) : base(ChatMessageType.ObjectChatMessage, LookupList, ResourceID, Variables, Styles) { this.sourceObjectID = SourceObjectID; this.sourceResourceID = SourceResourceID; this.transmissionType = TransmissionType; }
public ObjectChatMessage( uint SourceObjectID, uint SourceResourceID, ChatTransmissionType TransmissionType, LockingDictionary <uint, string> LookupList, uint ResourceID, List <InlineVariable> Variables, List <ChatStyle> Styles) : base(ChatMessageType.ObjectChatMessage, LookupList, ResourceID, Variables, Styles) { this.sourceObjectID = SourceObjectID; this.sourceResourceID = SourceResourceID; this.transmissionType = TransmissionType; }
public ChatMessage( ChatMessageType MessageType, LockingDictionary <uint, string> StringResources, uint ResourceID, List <InlineVariable> Variables, List <ChatStyle> Styles) { this.chatMessageType = MessageType; this.stringResources = StringResources; this.Variables = Variables; this.Styles = Styles; this.resourceID = ResourceID; }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string skill_name; string skill_description; StringResources.TryGetValue(skillNameID, out skill_name); StringResources.TryGetValue(skillDescriptionID, out skill_description); if (RaiseChangedEvent) { if (skill_name != null) { SkillName = skill_name; } else { SkillName = String.Empty; } if (skill_description != null) { SkillDescription = skill_description; } else { SkillDescription = String.Empty; } } else { if (skill_name != null) { skillName = skill_name; } else { skillName = String.Empty; } if (skill_description != null) { skillDescription = skill_description; } else { skillDescription = String.Empty; } } }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string bg_res; string bg_name; StringResources.TryGetValue(nameRID, out bg_res); StringResources.TryGetValue(overlayFileRID, out bg_name); if (RaiseChangedEvent) { if (bg_res != null) { OverlayFile = bg_res; } else { OverlayFile = String.Empty; } if (bg_name != null) { Name = bg_name; } else { Name = String.Empty; } } else { if (bg_res != null) { overlayFile = bg_res; } else { overlayFile = String.Empty; } if (bg_name != null) { name = bg_name; } else { name = String.Empty; } } }
/// <summary> /// Constructor /// </summary> public ResourceManager() { // string lookup dictionary StringResources = new LockingDictionary <uint, string>(); // maillist Mails = new MailList(200); // lookup dictionaries for resources Objects = new LockingDictionary <string, BgfFile>(StringComparer.OrdinalIgnoreCase); RoomTextures = new LockingDictionary <string, BgfFile>(StringComparer.OrdinalIgnoreCase); Rooms = new LockingDictionary <string, RooFile>(StringComparer.OrdinalIgnoreCase); Wavs = new LockingDictionary <string, Tuple <IntPtr, uint> >(StringComparer.OrdinalIgnoreCase); Music = new LockingDictionary <string, Tuple <IntPtr, uint> >(StringComparer.OrdinalIgnoreCase); }
/// <summary> /// Remove data from a Package /// <remark> /// If the data does not exist in the package nothing will be done /// </remark> /// </summary> /// <param name="packagePath">Path to the Package</param> /// <param name="storagePath">The relative path where data is stored inside the Package</param> public async Task RemoveDataFromPackageAsync(string packagePath, string storagePath) { var package = await RetrievePackageAsync(packagePath); var semaphore = LockingDictionary.GetOrAdd(packagePath, new SemaphoreSlim(1)); try { await semaphore.WaitAsync(); if (package.Entries.All(x => x.FullName != storagePath)) { return; } package.GetEntry(storagePath).Delete(); } finally { semaphore.Release(); } }
public LookMessage(LockingDictionary<uint, string> LookupList, byte[] Buffer, int StartIndex = 0) : base() { this.LookupList = LookupList; ReadFrom(Buffer, StartIndex); }
public LookMessage(ObjectInfo ObjectInfo, LockingDictionary<uint, string> LookupList) : base(MessageTypeGameMode.Look) { this.ObjectInfo = ObjectInfo; this.LookupList = LookupList; }
/// <summary> /// Constructor by values /// </summary> /// <param name="StringResources"></param> public RsbFile(LockingDictionary<uint, string> StringResources) { filename = DEFAULTFILENAME; stringResources = StringResources; }
public void ResolveStrings(LockingDictionary<uint, string> StringResources, bool RaiseChangedEvent) { string res_name; StringResources.TryGetValue(resourceID, out res_name); if (RaiseChangedEvent) { if (res_name != null) ResourceName = res_name; else ResourceName = String.Empty; } else { if (res_name != null) resourceName = res_name; else resourceName = String.Empty; } }
public MessageMessage(ChatMessage Message, LockingDictionary<uint, string> LookupList) : base(MessageTypeGameMode.Message) { this.LookupList = LookupList; this.Message = Message; }
public unsafe ObjectChatMessage(LockingDictionary<uint, string> LookupList, ref byte* Buffer) : base(ChatMessageType.ObjectChatMessage, LookupList, ref Buffer) { }
public MessageMessage(LockingDictionary <uint, string> LookupList, byte[] Buffer, int StartIndex = 0) : base() { this.LookupList = LookupList; ReadFrom(Buffer, StartIndex); }
public UserCommandMessage(UserCommand Command, LockingDictionary<uint, string> StringResources) : base(MessageTypeGameMode.UserCommand) { this.Command = Command; this.StringResources = StringResources; }
public override void ResolveStrings(LockingDictionary<uint, string> StringResources, bool RaiseChangedEvent) { base.ResolveStrings(StringResources, RaiseChangedEvent); foreach (SubOverlay obj in motionSubOverlays) obj.ResolveStrings(StringResources, RaiseChangedEvent); }
public ChatMessage( ChatMessageType MessageType, LockingDictionary<uint, string> StringResources, byte[] Buffer, int StartIndex = 0) { this.chatMessageType = MessageType; this.stringResources = StringResources; Variables = new List<InlineVariable>(); Styles = new List<ChatStyle>(); ReadFrom(Buffer, StartIndex); }
public unsafe MessageMessage(LockingDictionary<uint, string> LookupList, ref byte* Buffer) : base() { this.LookupList = LookupList; ReadFrom(ref Buffer); }
public MailMessage(LockingDictionary<uint, string> StringResources, byte[] Buffer, int StartIndex = 0) { stringResources = StringResources; ReadFrom(Buffer, StartIndex); }
/// <summary> /// Constructor /// </summary> /// <param name="StringResources"></param> public MessageControllerClient(LockingDictionary<uint, string> StringResources) : base(StringResources) { }
public void ResolveStrings(LockingDictionary<uint, string> StringResources, bool RaiseChangedEvent) { string skill_name; string skill_description; StringResources.TryGetValue(skillNameID, out skill_name); StringResources.TryGetValue(skillDescriptionID, out skill_description); if (RaiseChangedEvent) { if (skill_name != null) SkillName = skill_name; else SkillName = String.Empty; if (skill_description != null) SkillDescription = skill_description; else SkillDescription = String.Empty; } else { if (skill_name != null) skillName = skill_name; else skillName = String.Empty; if (skill_description != null) skillDescription = skill_description; else skillDescription = String.Empty; } }
public ObjectChatMessage(LockingDictionary<uint, string> LookupList, byte[] Buffer, int StartIndex = 0) : base(ChatMessageType.ObjectChatMessage, LookupList, Buffer, StartIndex) { }
public SaidMessage(LockingDictionary<uint, string> StringResources, byte[] Buffer, int StartIndex = 0) : base() { this.StringResources = StringResources; ReadFrom(Buffer, StartIndex); }
/// <summary> /// Constructor /// </summary> /// <param name="StringResources">Resources</param> /// <param name="AdvanceHashTable"></param> public MessageControllerHook(LockingDictionary<uint, string> StringResources, bool AdvanceHashTable) : base(StringResources) { this.advanceHashTable = AdvanceHashTable; }
/// <summary> /// Constructor. /// </summary> /// <param name="StringResources">The StringResources to use.</param> public ServerConnection(LockingDictionary<uint, string> StringResources) { // init the queues (receive, send, logs, exceptions) ReceiveQueue = new LockingQueue<GameMessage>(); SendQueue = new LockingQueue<GameMessage>(); ExceptionQueue = new LockingQueue<Exception>(); // the debugqueue to give back sent packets (with crc/...) if activated OutgoingPacketLog = new LockingQueue<GameMessage>(); // save reference to string dictionary stringResources = StringResources; // setup the packetcontroller messageController = new MessageControllerClient(StringResources); // hook up listeners messageController.MessageAvailable += new GameMessageEventHandler(OnMessageControllerNewMessageAvailable); messageController.ServerSaveChanged += new ServerSaveChangedEventHandler(OnMessageControllerNewServerSave); messageController.HandlerError += new HandlerErrorEventHandler(OnMessageControllerHandlerError); messageController.ProtocolModeChanged += new EventHandler(OnMessageControllerProtocolModeChanged); // setup the ping timer timPing = new System.Timers.Timer(); timPing.Enabled = false; timPing.Interval = PINGINTERVAL; timPing.Elapsed += new ElapsedEventHandler(OnPingTimerElapsed); }
public MessageMessage(ChatMessage Message, LockingDictionary <uint, string> LookupList) : base(MessageTypeGameMode.Message) { this.LookupList = LookupList; this.Message = Message; }
public UserCommandLookPlayer(LockingDictionary<uint, string> LookupList, byte[] Buffer, int StartIndex = 0) { stringResources = LookupList; ReadFrom(Buffer, StartIndex); }
public unsafe MessageMessage(LockingDictionary <uint, string> LookupList, ref byte *Buffer) : base() { this.LookupList = LookupList; ReadFrom(ref Buffer); }
public void ResolveStrings(LockingDictionary <uint, string> StringResources, bool RaiseChangedEvent) { string avatar_name; string avatar_overlay; string room_file; string room_name; string background_file; string wading_file; StringResources.TryGetValue(avatarOverlayRID, out avatar_overlay); StringResources.TryGetValue(avatarNameRID, out avatar_name); StringResources.TryGetValue(roomFileRID, out room_file); StringResources.TryGetValue(roomNameRID, out room_name); StringResources.TryGetValue(backgroundFileRID, out background_file); StringResources.TryGetValue(wadingSoundFileRID, out wading_file); if (RaiseChangedEvent) { if (avatar_name != null) { AvatarName = avatar_name; } else { AvatarName = String.Empty; } if (avatar_overlay != null) { AvatarOverlay = avatar_overlay; } else { AvatarOverlay = String.Empty; } if (room_file != null) { RoomFile = room_file; } else { RoomFile = String.Empty; } if (room_name != null) { RoomName = room_name; } else { RoomName = String.Empty; } if (background_file != null) { BackgroundFile = background_file; } else { BackgroundFile = String.Empty; } if (wading_file != null) { WadingSoundFile = wading_file; } else { WadingSoundFile = String.Empty; } } else { if (avatar_name != null) { avatarName = avatar_name; } else { avatarName = String.Empty; } if (avatar_overlay != null) { avatarOverlay = avatar_overlay; } else { avatarOverlay = String.Empty; } if (room_file != null) { roomFile = room_file; } else { roomFile = String.Empty; } if (room_name != null) { roomName = room_name; } else { roomName = String.Empty; } if (background_file != null) { backgroundFile = background_file; } else { backgroundFile = String.Empty; } if (wading_file != null) { wadingSoundFile = wading_file; } else { wadingSoundFile = String.Empty; } } }
public void ResolveStrings(LockingDictionary<uint, string> StringResources, bool RaiseChangedEvent) { string res_mainoverlayname; StringResources.TryGetValue(overlayFileRID, out res_mainoverlayname); if (RaiseChangedEvent) { if (res_mainoverlayname != null) OverlayFile = res_mainoverlayname; else OverlayFile = String.Empty; } else { if (res_mainoverlayname != null) overlayFile = res_mainoverlayname; else overlayFile = String.Empty; } }
public void ResolveStrings(LockingDictionary<uint, string> StringResources, bool RaiseChangedEvent) { string res_name; string res_mainoverlayname; StringResources.TryGetValue(nameRID, out res_name); StringResources.TryGetValue(overlayFileRID, out res_mainoverlayname); if (RaiseChangedEvent) { if (res_name != null) Name = res_name; else Name = String.Empty; if (res_mainoverlayname != null) OverlayFile = res_mainoverlayname; else OverlayFile = String.Empty; } else { if (res_name != null) name = res_name; else name = String.Empty; if (res_mainoverlayname != null) overlayFile = res_mainoverlayname; else overlayFile = String.Empty; } foreach (SubOverlay obj in subOverlays) obj.ResolveStrings(StringResources, RaiseChangedEvent); foreach (SubOverlay obj in motionSubOverlays) obj.ResolveStrings(StringResources, RaiseChangedEvent); }
public SaidMessage(ObjectChatMessage Message, LockingDictionary<uint, string> LookupList) : base(MessageTypeGameMode.Said) { this.StringResources = LookupList; this.Message = Message; }
/// <summary> /// Parses a typed UserCommand subclass instance from a raw byte buffer. /// </summary> /// <param name="IsOutgoing">Outgoing (client->server) direction or not. This must be correct for some commands or will create parser errors.</param> /// <param name="StringResources">Reference to the string dictionary containing game strings.</param> /// <param name="Buffer">Buffer with bytes to read from</param> /// <param name="StartIndex">StartIndex for reading</param> /// <param name="Length">This is required to parse unknown UserCommandGeneric.</param> /// <returns>Subclass instance of UserCommand or UserCommandGeneric for unknown ones</returns> public static UserCommand ExtractCommand( bool IsOutgoing, LockingDictionary<uint, string> StringResources, byte[] Buffer, int StartIndex, int Length) { UserCommand returnValue = null; // try to parse the command switch ((UserCommandType)Buffer[StartIndex]) { case UserCommandType.LookPlayer: // 2 returnValue = new UserCommandLookPlayer(StringResources, Buffer, StartIndex); break; case UserCommandType.ChangeURL: // 3 returnValue = new UserCommandChangeURL(Buffer, StartIndex); break; case UserCommandType.Rest: // 5 returnValue = new UserCommandRest(Buffer, StartIndex); break; case UserCommandType.Stand: // 6 returnValue = new UserCommandStand(Buffer, StartIndex); break; case UserCommandType.Safety: // 7 returnValue = new UserCommandSafety(Buffer, StartIndex); break; case UserCommandType.Suicide: // 8 returnValue = new UserCommandSuicide(Buffer, StartIndex); break; #if !VANILLA case UserCommandType.TempSafe: // 9 returnValue = new UserCommandTempSafe(Buffer, StartIndex); break; #endif case UserCommandType.GuildInfo: // 11 returnValue = new UserCommandGuildInfo(Buffer, StartIndex); break; case UserCommandType.Invite: // 12 returnValue = new UserCommandGuildInvite(Buffer, StartIndex); break; case UserCommandType.Exile: // 13 returnValue = new UserCommandGuildExile(Buffer, StartIndex); break; case UserCommandType.Renounce: // 14 returnValue = new UserCommandGuildRenounce(Buffer, StartIndex); break; case UserCommandType.Abdicate: // 15 returnValue = new UserCommandGuildAbdicate(Buffer, StartIndex); break; case UserCommandType.Vote: // 16 returnValue = new UserCommandGuildVote(Buffer, StartIndex); break; case UserCommandType.SetRank: // 17 returnValue = new UserCommandGuildSetRank(Buffer, StartIndex); break; case UserCommandType.GuildAsk: // 18 returnValue = new UserCommandGuildAsk(Buffer, StartIndex); break; case UserCommandType.Disband: // 20 returnValue = new UserCommandGuildDisband(Buffer, StartIndex); break; case UserCommandType.ReqGuildList: // 21 returnValue = new UserCommandGuildGuildListReq(Buffer, StartIndex); break; case UserCommandType.GuildList: // 22 returnValue = new UserCommandGuildGuildList(Buffer, StartIndex); break; case UserCommandType.MakeAlliance: // 23 returnValue = new UserCommandGuildMakeAlliance(Buffer, StartIndex); break; case UserCommandType.EndAlliance: // 24 returnValue = new UserCommandGuildEndAlliance(Buffer, StartIndex); break; case UserCommandType.MakeEnemy: // 25 returnValue = new UserCommandGuildMakeEnemy(Buffer, StartIndex); break; case UserCommandType.EndEnemy: // 26 returnValue = new UserCommandGuildEndEnemy(Buffer, StartIndex); break; case UserCommandType.GuildSetPassword: // 30 returnValue = new UserCommandGuildSetPassword(Buffer, StartIndex); break; case UserCommandType.GuildShield: // 31 if (IsOutgoing) returnValue = new UserCommandGuildShieldInfoReq(Buffer, StartIndex); else returnValue = new UserCommandGuildShieldInfo(Buffer, StartIndex); break; case UserCommandType.GuildShields: // 32 if (IsOutgoing) returnValue = new UserCommandGuildShieldListReq(Buffer, StartIndex); else returnValue = new UserCommandGuildShieldList(Buffer, StartIndex); break; case UserCommandType.ClaimShield: // 33 returnValue = new UserCommandClaimShield(Buffer, StartIndex); break; #if !VANILLA case UserCommandType.Grouping: // 34 returnValue = new UserCommandGrouping(Buffer, StartIndex); break; #endif case UserCommandType.Deposit: // 35 returnValue = new UserCommandDeposit(Buffer, StartIndex); break; case UserCommandType.WithDraw: // 36 returnValue = new UserCommandWithDraw(Buffer, StartIndex); break; default: returnValue = new UserCommandGeneric(Buffer, StartIndex, Length); break; } return returnValue; }
public unsafe SaidMessage(LockingDictionary<uint, string> StringResources, ref byte* Buffer) : base() { this.StringResources = StringResources; ReadFrom(ref Buffer); }
public unsafe ChatMessage( ChatMessageType MessageType, LockingDictionary<uint, string> StringResources, ref byte* Buffer) { this.chatMessageType = MessageType; this.stringResources = StringResources; Variables = new List<InlineVariable>(); Styles = new List<ChatStyle>(); ReadFrom(ref Buffer); }