Revert "Updates Packets & Randomizer (#43)" (#61)

This reverts commit 179cb50557.
This commit is contained in:
Kamron Batman 2019-11-11 08:46:11 -08:00 • committed by GitHub
parent 179cb50557
commit c2ecc76457
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
588 changed files with 16260 additions and 10926 deletions

View file

@ -24,14 +24,14 @@ using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Threading;
using Server.Guilds;
using Server.Network;
using Server.Persistence;
namespace Server
{
public static class World
{
private static readonly ManualResetEvent m_DiskWriteHandle = new ManualResetEvent(true);
private static ManualResetEvent m_DiskWriteHandle = new ManualResetEvent(true);
private static Queue<IEntity> _addQueue, _deleteQueue;
@ -91,19 +91,22 @@ namespace Server
public static void Broadcast(int hue, bool ascii, string text)
{
Packet p;
if (ascii)
p = new AsciiMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text);
else
p = new UnicodeMessage(Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text);
List<NetState> list = NetState.Instances;
for (int i = 0; i < list.Count; ++i)
{
NetState state = list[i];
if (state == null)
continue;
p.Acquire();
if (ascii)
Packets.SendAsciiMessage(state, Serial.MinusOne, -1, MessageType.Regular, hue, 3, "System", text);
else
Packets.SendUnicodeMessage(state, Serial.MinusOne, -1, MessageType.Regular, hue, 3, "ENU", "System", text);
}
for (int i = 0; i < list.Count; ++i)
if (list[i].Mobile != null)
list[i].Send(p);
p.Release();
}
public static void Broadcast(int hue, bool ascii, string format, params object[] args)
@ -176,6 +179,8 @@ namespace Server
_addQueue = new Queue<IEntity>();
_deleteQueue = new Queue<IEntity>();
int mobileCount, itemCount, guildCount;
object[] ctorArgs = new object[1];
List<ItemEntry> items = new List<ItemEntry>();
@ -569,7 +574,7 @@ namespace Server
}
}
private static void SaveIndex<T>(IReadOnlyList<T> list, string path) where T : IEntityEntry
private static void SaveIndex<T>(List<T> list, string path) where T : IEntityEntry
{
if (!Directory.Exists("Saves/Mobiles/"))
Directory.CreateDirectory("Saves/Mobiles/");
@ -598,10 +603,12 @@ namespace Server
idxWriter.Close();
}
idxWriter.Close();
public static void Save()
{
Save(true, false);
}
public static void Save(bool message = true, bool permitBackgroundWrite = false)
public static void Save(bool message, bool permitBackgroundWrite)
{
if (Saving)
return;
@ -665,7 +672,15 @@ namespace Server
NetState.Resume();
}
public static IEntity FindEntity(Serial serial) => serial.IsItem ? (IEntity)FindItem(serial) : serial.IsMobile ? FindMobile(serial) : null;
public static IEntity FindEntity(Serial serial)
{
if (serial.IsItem)
return FindItem(serial);
if (serial.IsMobile)
return FindMobile(serial);
return null;
}
public static Mobile FindMobile(Serial serial)
{