Skip to content

Commit 7d05e3b

Browse files
authored
fix: Codegens ToT and replaces persistence with config (#1524)
1 parent 5ea5fb4 commit 7d05e3b

File tree

40 files changed

+1252
-1736
lines changed

40 files changed

+1252
-1736
lines changed

Projects/UOContent/Engines/Treasures of Tokuno/BasePigmentsOfTokuno.cs

Lines changed: 180 additions & 238 deletions
Large diffs are not rendered by default.

Projects/UOContent/Engines/Treasures of Tokuno/GreaterArtifacts.cs

Lines changed: 288 additions & 479 deletions
Large diffs are not rendered by default.

Projects/UOContent/Engines/Treasures of Tokuno/LesserArtifacts.cs

Lines changed: 521 additions & 932 deletions
Large diffs are not rendered by default.

Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokuno.cs

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
using System;
22
using System.Collections.Generic;
3+
using System.IO;
34
using System.Linq;
5+
using ModernUO.Serialization;
46
using Server.Gumps;
57
using Server.Items;
8+
using Server.Json;
69
using Server.Misc;
710
using Server.Mobiles;
811
using Server.Multis;
@@ -20,8 +23,15 @@ public enum TreasuresOfTokunoEra
2023
ToTThree
2124
}
2225

26+
public class ToTConfig
27+
{
28+
public TreasuresOfTokunoEra DropEra { get; set; }
29+
public TreasuresOfTokunoEra RewardEra { get; set; }
30+
}
31+
2332
public static class TreasuresOfTokuno
2433
{
34+
public const string ToTConfigurationPath = "Configuration/tot.json";
2535
public const int ItemsPerReward = 10;
2636

2737
private static readonly Type[][] m_LesserArtifacts =
@@ -86,9 +96,45 @@ public static class TreasuresOfTokuno
8696
typeof(BaseFormTalisman), typeof(BaseWand), typeof(JesterHatofChuckles)
8797
};
8898

89-
public static TreasuresOfTokunoEra DropEra { get; set; } = TreasuresOfTokunoEra.None;
99+
public static void Configure()
100+
{
101+
var pathToTFile = Path.Combine(Core.BaseDirectory, ToTConfigurationPath);
102+
_totConfig = File.Exists(pathToTFile)
103+
? JsonConfig.Deserialize<ToTConfig>(pathToTFile)
104+
: new ToTConfig
105+
{
106+
DropEra = TreasuresOfTokunoEra.None,
107+
RewardEra = TreasuresOfTokunoEra.ToTOne,
108+
};
109+
}
110+
111+
private static ToTConfig _totConfig;
112+
113+
public static TreasuresOfTokunoEra DropEra
114+
{
115+
get => _totConfig.DropEra;
116+
set
117+
{
118+
_totConfig.DropEra = value;
119+
SaveConfiguration();
120+
}
121+
}
122+
123+
public static TreasuresOfTokunoEra RewardEra
124+
{
125+
get => _totConfig.RewardEra;
126+
set
127+
{
128+
_totConfig.RewardEra = value;
129+
SaveConfiguration();
130+
}
131+
}
90132

91-
public static TreasuresOfTokunoEra RewardEra { get; set; } = TreasuresOfTokunoEra.ToTOne;
133+
private static void SaveConfiguration()
134+
{
135+
var pathToTFile = Path.Combine(Core.BaseDirectory, ToTConfigurationPath);
136+
JsonConfig.Serialize(pathToTFile, _totConfig);
137+
}
92138

93139
public static Type[] LesserArtifacts => m_LesserArtifacts[(int)RewardEra - 1];
94140

@@ -203,7 +249,8 @@ public static void HandleKill(Mobile victim, Mobile killer)
203249

204250
namespace Server.Mobiles
205251
{
206-
public class IharaSoko : BaseVendor
252+
[SerializationGenerator(0, false)]
253+
public partial class IharaSoko : BaseVendor
207254
{
208255
protected List<SBInfo> m_SBInfos = new();
209256

@@ -215,10 +262,6 @@ public IharaSoko() : base("the Imperial Minister of Trade")
215262
Hue = 0x8403;
216263
}
217264

218-
public IharaSoko(Serial serial) : base(serial)
219-
{
220-
}
221-
222265
public override bool IsActiveVendor => false;
223266
public override bool IsInvulnerable => true;
224267
public override bool DisallowAllMoves => true;
@@ -243,20 +286,6 @@ public override void InitOutfit()
243286
AddItem(item);
244287
}
245288

246-
public override void Serialize(IGenericWriter writer)
247-
{
248-
base.Serialize(writer);
249-
250-
writer.Write(0);
251-
}
252-
253-
public override void Deserialize(IGenericReader reader)
254-
{
255-
base.Deserialize(reader);
256-
257-
var version = reader.ReadInt();
258-
}
259-
260289
public override bool CanBeDamaged() => false;
261290

262291
public override void OnMovement(Mobile m, Point3D oldLocation)
@@ -302,7 +331,7 @@ public override void OnMovement(Mobile m, Point3D oldLocation)
302331
}
303332
}
304333

305-
var leaveRange = 7;
334+
const int leaveRange = 7;
306335

307336
if (!InRange(m, leaveRange) && InRange(oldLocation, leaveRange))
308337
{

Projects/UOContent/Engines/Treasures of Tokuno/TreasuresOfTokunoPersistance.cs

Lines changed: 0 additions & 65 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
3+
namespace Server.Misc;
4+
5+
[ManualDirtyChecking]
6+
[TypeAlias("Server.Misc.TreasuresOfTokunoPersistance")]
7+
[Obsolete("Deprecated in favor of a configuration file. Only used for legacy deserialization")]
8+
public class TreasuresOfTokunoPersistence : Item
9+
{
10+
public TreasuresOfTokunoPersistence() : base(1) => Movable = false;
11+
12+
public TreasuresOfTokunoPersistence(Serial serial) : base(serial)
13+
{
14+
}
15+
16+
public override void Serialize(IGenericWriter writer)
17+
{
18+
base.Serialize(writer);
19+
}
20+
21+
public override void Deserialize(IGenericReader reader)
22+
{
23+
base.Deserialize(reader);
24+
25+
var version = reader.ReadInt();
26+
27+
TreasuresOfTokuno.RewardEra = (TreasuresOfTokunoEra)reader.ReadEncodedInt();
28+
TreasuresOfTokuno.DropEra = (TreasuresOfTokunoEra)reader.ReadEncodedInt();
29+
30+
Timer.DelayCall(Delete);
31+
}
32+
}

Projects/UOContent/Migrations/Server.Items.AncientFarmersKasa.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.AncientSamuraiDo.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.AncientUrn.v0.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.ArmsOfTacticalExcellence.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.BasePigmentsOfTokuno.v0.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.BlackLotusHood.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.ChestOfHeirlooms.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.DaimyosHelm.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.DarkenedSky.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.DemonForks.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.DragonNunchaku.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.Exiler.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.FluteOfRenewal.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.GlovesOfTheSun.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.HanzosBow.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.HonorableSwords.v0.json

Lines changed: 14 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.KasaOfTheRajin.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.LegsOfStability.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.LesserPigmentsOfTokuno.v0.json

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.LeurociansMempoOfFortune.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.MetalPigmentsOfTokuno.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Projects/UOContent/Migrations/Server.Items.PeasantsBokuto.v0.json

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)