Skip to content

Commit

Permalink
Merge pull request #55 from Supamiu/master
Browse files Browse the repository at this point in the history
Cleanup and support for FreeCompanyDialog
  • Loading branch information
karashiiro authored Apr 14, 2021
2 parents 0dbe4d8 + 739efc8 commit f5aa94b
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions PacketDetection/ScannerRegistry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@ private void DeclareScanners()
//=================
RegisterScanner("Playtime", "Please type /playtime.",
PacketSource.Server,
(packet, parameters) => {
(packet, parameters) =>
{
if (packet.PacketSize != 40 || packet.SourceActor != packet.TargetActor) return false;
var playtime = BitConverter.ToUInt32(packet.Data, (int)Offsets.IpcData);
Expand Down Expand Up @@ -129,7 +130,8 @@ private void DeclareScanners()
const int marketBoardItemDetectionId = 17837; // Grade 7 Dark Matter
RegisterScanner("MarketBoardSearchResult", "Please click \"Catalysts\" on the market board.",
PacketSource.Server,
(packet, _) => {
(packet, _) =>
{
if (packet.PacketSize != 208) return false;
for (var i = 0; i < 22; ++i)
Expand Down Expand Up @@ -306,7 +308,8 @@ private void DeclareScanners()
uint inventoryModifyHandlerId = 0;
RegisterScanner("InventoryModifyHandler", "Please drop the Pill Bug.",
PacketSource.Client,
(packet, _, comment) => {
(packet, _, comment) =>
{
var match = packet.PacketSize == 80 && BitConverter.ToUInt16(packet.Data, Offsets.IpcData + 0x18) == 2587;
if (!match) return false;
Expand All @@ -321,7 +324,8 @@ private void DeclareScanners()
(packet, _) => packet.PacketSize == 48 && BitConverter.ToUInt32(packet.Data, Offsets.IpcData) == inventoryModifyHandlerId);
RegisterScanner("InventoryTransaction", "Please wait.",
PacketSource.Server,
(packet, _) => {
(packet, _) =>
{
var match = packet.PacketSize == 80 && BitConverter.ToUInt16(packet.Data, Offsets.IpcData + 0x18) == 2587;
if (!match) return false;
Expand Down Expand Up @@ -401,7 +405,7 @@ private void DeclareScanners()
//=================
RegisterScanner("PlaceFieldMarkerPreset", "Please type /waymark clear",
PacketSource.Server,
(packet, _) =>
(packet, _) =>
{
if (packet.PacketSize != 136 || packet.SourceActor != packet.TargetActor) return false;
Expand All @@ -425,12 +429,6 @@ private void DeclareScanners()
PacketSource.Server,
(packet, _) => packet.PacketSize == 156 && BitConverter.ToUInt16(packet.Data, Offsets.IpcData + 8) == 16533);
//=================
RegisterScanner("AddStatusEffect", "Please use Dia.",
PacketSource.Server,
(packet, _) =>
packet.PacketSize == 128 && BitConverter.ToUInt16(packet.Data, Offsets.IpcData + 30) == 1871 ||
packet.PacketSize == 120 && BitConverter.ToUInt16(packet.Data, Offsets.IpcData + 26) == 1871);
//=================
RegisterScanner("StatusEffectList", "Please wait...",
PacketSource.Server,
(packet, _) => packet.PacketSize == 416 && BitConverter.ToUInt16(packet.Data, Offsets.IpcData + 20) == 1871);
Expand Down Expand Up @@ -475,10 +473,18 @@ private void DeclareScanners()
digit <= 9;
});
//=================
int fcRank = 0;
RegisterScanner("FreeCompanyInfo", "Load a zone.",
PacketSource.Server,
(packet, parameters) => packet.PacketSize == 112 && packet.Data[Offsets.IpcData + 45] == int.Parse(parameters[0]),
(packet, parameters) =>
{
fcRank = int.Parse(parameters[0]);
return packet.PacketSize == 112 && packet.Data[Offsets.IpcData + 45] == fcRank;
},
new[] { "Please enter your Free Company rank:" });
RegisterScanner("FreeCompanyDialog", "Open your Free Company window (press G)",
PacketSource.Server,
(packet, _) => packet.PacketSize == 112 && packet.Data[Offsets.IpcData + 0x31] == fcRank);
//=================
RegisterScanner("AirshipTimers", "Open your Estate tab from the Timers window if you have any airships on exploration.",
PacketSource.Server,
Expand All @@ -502,7 +508,7 @@ private void DeclareScanners()
new[] { "Please enter the experience from the first sector:" });
RegisterScanner("SubmarineProgressionStatus", "Open your submarine management console if you have any submarines",
PacketSource.Server,
(packet, parameters) => packet.PacketSize == 56 && packet.Data[Offsets.IpcData] >= 1 && packet.Data[Offsets.IpcData] <= 4);
(packet, parameters) => packet.PacketSize == 56 && packet.Data[Offsets.IpcData] >= 1 && packet.Data[Offsets.IpcData] <= 4);
RegisterScanner("SubmarineStatusList", "Open your submarine management console if you have any submarines",
PacketSource.Server,
(packet, parameters) => packet.PacketSize == 272 && IncludesBytes(packet.Data, Encoding.UTF8.GetBytes(parameters[0])),
Expand Down

0 comments on commit f5aa94b

Please sign in to comment.