feat: Moves network related events to UOContent using code generation (#1945)

### Summary
- Moves `CharacterCreated` event to UOContent using code generated event _CharacterCreatedEvent_.
- Moves `TargetByResourceMacro` event to UOContent using code generated event _TargetByResourceMacro_.
- Moves `GameLogin` event to UOContent using code generated event _GameLoginEvent_.
- Moves `ServerList` event to UOContent using code generated event _ServerListEvent_.
- Streamlines ProfessionInfo


> [!IMPORTANT]
> **Developer Note**
> Custom scripts that use any of these event sinks will need to be updated to use the new code generated events.
This commit is contained in:
Kamron Batman 2024-09-06 16:57:10 -07:00 • committed by GitHub
parent 4110556e89
commit 47e16a03fe
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 207 additions and 309 deletions

File diff suppressed because it is too large Load diff

View file

@ -49,8 +49,6 @@ public class ProfessionInfo
static ProfessionInfo()
{
List<ProfessionInfo> profs = [];
var file = Core.FindDataFile("prof.txt", false);
if (!File.Exists(file))
{
@ -58,10 +56,11 @@ public class ProfessionInfo
file = Path.Combine(ExpansionInfo.GetEraFolder(parent), "prof.txt");
}
var maxProf = 0;
if (File.Exists(file))
{
var maxProf = 0;
List<ProfessionInfo> profs = [];
using var s = File.OpenText(file);
while (!s.EndOfStream)
@ -82,7 +81,6 @@ public class ProfessionInfo
var prof = new ProfessionInfo();
var statIndex = 0;
var totalStats = 0;
var skillIndex = 0;
var totalSkill = 0;
@ -161,8 +159,8 @@ public class ProfessionInfo
break;
}
var skillValue = Utility.ToInt32(cols[2]);
prof.Skills[skillIndex++] = new SkillNameValue(skillName, skillValue);
var skillValue = byte.Parse(cols[2]);
prof.Skills[skillIndex++] = (skillName, skillValue);
totalSkill += skillValue;
}
break;
@ -173,39 +171,44 @@ public class ProfessionInfo
break;
}
var statValue = Utility.ToInt32(cols[2]);
prof.Stats[statIndex++] = new StatNameValue(stat, statValue);
var statValue = byte.Parse(cols[2]);
prof.Stats[(int)stat >> 1] = statValue;
totalStats += statValue;
}
break;
}
}
}
_professions = new ProfessionInfo[maxProf + 1];
foreach (var p in profs)
{
_professions[p.ID] = p;
}
profs.Clear();
profs.TrimExcess();
}
else
{
_professions = new ProfessionInfo[1];
}
_professions = new ProfessionInfo[maxProf + 1];
_professions[0] = new ProfessionInfo
{
Name = "Advanced Skills"
};
foreach (var p in profs)
{
_professions[p.ID] = p;
}
profs.Clear();
profs.TrimExcess();
}
private SkillNameValue[] _skills;
private (SkillName, byte)[] _skills;
private ProfessionInfo()
{
Name = string.Empty;
_skills = new SkillNameValue[4];
Stats = new StatNameValue[3];
_skills = new (SkillName, byte)[4];
Stats = new byte[3];
}
public int ID { get; private set; }
@ -214,8 +217,8 @@ public class ProfessionInfo
public int DescID { get; private set; }
public bool TopLevel { get; private set; }
public int GumpID { get; private set; }
public SkillNameValue[] Skills => _skills;
public StatNameValue[] Stats { get; }
public (SkillName, byte)[] Skills => _skills;
public byte[] Stats { get; }
public void FixSkills()
{
@ -223,7 +226,7 @@ public class ProfessionInfo
while (index >= 0)
{
var skill = _skills[index];
if (skill is not { Name: SkillName.Alchemy, Value: 0 })
if (skill is not (SkillName.Alchemy, 0))
{
break;
}

View file

@ -3,6 +3,7 @@ using System.Net;
using System.Net.Http;
using System.Net.NetworkInformation;
using System.Net.Sockets;
using ModernUO.CodeGeneratedEvents;
using Server.Logging;
using Server.Network;
@ -60,11 +61,10 @@ namespace Server.Misc
{
Resolve(Address, out _publicAddress);
}
EventSink.ServerList += EventSink_ServerList;
}
private static void EventSink_ServerList(ServerListEventArgs e)
[OnEvent(nameof(GatewayServer.ServerListEvent))]
public static void OnServerListEvent(GatewayServer.ServerListEventArgs e)
{
try
{