Skip to content

Commit ea95069

Browse files
Fix reference scripts;
1 parent 40aa8e0 commit ea95069

File tree

4 files changed

+36
-34
lines changed

4 files changed

+36
-34
lines changed

XtractQuery/CrossCutting.Core.Configuration.File/FileConfigurationRepository.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public IEnumerable<ConfigCategory> Load()
3535

3636
private string GetConfigPath()
3737
{
38-
return Path.Combine(Environment.ProcessPath!, "config.json");
38+
return Path.Combine(Path.GetDirectoryName(Environment.ProcessPath)!, "config.json");
3939
}
4040
}
4141
}

XtractQuery/Logic.Domain.Level5/Logic.Domain.Level5/Script/Xq32/Xq32ScriptReader.cs

+13-13
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ namespace Logic.Domain.Level5.Script.Xq32
99
internal class Xq32ScriptReader : ScriptReader<Xq32Function, Xq32Jump, Xq32Instruction, Xq32Argument>, IXq32ScriptReader
1010
{
1111
private readonly IBinaryFactory _binaryFactory;
12-
private readonly Dictionary<uint, IList<string>> _functionCache;
13-
private readonly Dictionary<uint, IList<string>> _jumpCache;
12+
private readonly Dictionary<uint, HashSet<string>> _functionCache;
13+
private readonly Dictionary<uint, HashSet<string>> _jumpCache;
1414

1515
public Xq32ScriptReader(IXq32ScriptDecompressor decompressor, IXq32ScriptEntrySizeProvider entrySizeProvider,
1616
IBinaryFactory binaryFactory)
1717
: base(decompressor, entrySizeProvider, binaryFactory)
1818
{
1919
_binaryFactory = binaryFactory;
20-
_functionCache = new Dictionary<uint, IList<string>>();
21-
_jumpCache = new Dictionary<uint, IList<string>>();
20+
_functionCache = new Dictionary<uint, HashSet<string>>();
21+
_jumpCache = new Dictionary<uint, HashSet<string>>();
2222
}
2323

2424
public override IReadOnlyList<Xq32Function> ReadFunctions(Stream functionStream, int entryCount, PointerLength length)
@@ -185,8 +185,8 @@ protected override ScriptFunction CreateFunction(Xq32Function function, IBinaryR
185185
stringReader.BaseStream.Position = function.nameOffset;
186186
name = stringReader.ReadCStringSJIS();
187187

188-
if (!_functionCache.TryGetValue(function.crc32, out IList<string>? functionNames))
189-
_functionCache[function.crc32] = functionNames = new List<string>();
188+
if (!_functionCache.TryGetValue(function.crc32, out HashSet<string>? functionNames))
189+
_functionCache[function.crc32] = functionNames = new HashSet<string>();
190190

191191
functionNames.Add(name);
192192
}
@@ -216,8 +216,8 @@ protected override ScriptJump CreateJump(Xq32Jump jump, IBinaryReaderX? stringRe
216216
stringReader.BaseStream.Position = jump.nameOffset;
217217
name = stringReader.ReadCStringSJIS();
218218

219-
if (!_jumpCache.TryGetValue(jump.crc32, out IList<string>? jumpNames))
220-
_jumpCache[jump.crc32] = jumpNames = new List<string>();
219+
if (!_jumpCache.TryGetValue(jump.crc32, out HashSet<string>? jumpNames))
220+
_jumpCache[jump.crc32] = jumpNames = new HashSet<string>();
221221

222222
jumpNames.Add(name);
223223
}
@@ -262,7 +262,7 @@ protected override ScriptArgument CreateArgument(Xq32Argument argument, int inst
262262

263263
if (argumentIndex != 0)
264264
{
265-
if (_functionCache.TryGetValue((ushort)argument.value, out IList<string>? names)
265+
if (_functionCache.TryGetValue((ushort)argument.value, out HashSet<string>? names)
266266
|| _jumpCache.TryGetValue((ushort)argument.value, out names))
267267
value = names.First();
268268
break;
@@ -271,22 +271,22 @@ protected override ScriptArgument CreateArgument(Xq32Argument argument, int inst
271271
switch (instructionType)
272272
{
273273
case 20:
274-
if (_functionCache.TryGetValue((ushort)argument.value, out IList<string>? names))
274+
if (_functionCache.TryGetValue(argument.value, out HashSet<string>? names))
275275
value = names.First();
276276
break;
277277

278278
case 30:
279-
if (_jumpCache.TryGetValue((ushort)argument.value, out names))
279+
if (_jumpCache.TryGetValue(argument.value, out names))
280280
value = names.First();
281281
break;
282282

283283
case 31:
284-
if (_jumpCache.TryGetValue((ushort)argument.value, out names))
284+
if (_jumpCache.TryGetValue(argument.value, out names))
285285
value = names.First();
286286
break;
287287

288288
case 33:
289-
if (_jumpCache.TryGetValue((ushort)argument.value, out names))
289+
if (_jumpCache.TryGetValue(argument.value, out names))
290290
value = names.First();
291291
break;
292292
}

XtractQuery/Logic.Domain.Level5/Logic.Domain.Level5/Script/Xseq/XseqScriptReader.cs

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ namespace Logic.Domain.Level5.Script.Xseq
99
internal class XseqScriptReader : ScriptReader<XseqFunction, XseqJump, XseqInstruction, XseqArgument>, IXseqScriptReader
1010
{
1111
private readonly IBinaryFactory _binaryFactory;
12-
private readonly Dictionary<ushort, IList<string>> _functionCache;
13-
private readonly Dictionary<ushort, IList<string>> _jumpCache;
12+
private readonly Dictionary<ushort, HashSet<string>> _functionCache;
13+
private readonly Dictionary<ushort, HashSet<string>> _jumpCache;
1414

1515
public XseqScriptReader(IXseqScriptDecompressor decompressor, IXseqScriptEntrySizeProvider entrySizeProvider,
1616
IBinaryFactory binaryFactory)
1717
: base(decompressor, entrySizeProvider, binaryFactory)
1818
{
1919
_binaryFactory = binaryFactory;
20-
_functionCache = new Dictionary<ushort, IList<string>>();
21-
_jumpCache = new Dictionary<ushort, IList<string>>();
20+
_functionCache = new Dictionary<ushort, HashSet<string>>();
21+
_jumpCache = new Dictionary<ushort, HashSet<string>>();
2222
}
2323

2424
public override IReadOnlyList<XseqFunction> ReadFunctions(Stream functionStream, int entryCount, PointerLength length)
@@ -179,8 +179,8 @@ protected override ScriptFunction CreateFunction(XseqFunction function, IBinaryR
179179
stringReader.BaseStream.Position = function.nameOffset;
180180
name = stringReader.ReadCStringSJIS();
181181

182-
if (!_functionCache.TryGetValue(function.crc16, out IList<string>? functionNames))
183-
_functionCache[function.crc16] = functionNames = new List<string>();
182+
if (!_functionCache.TryGetValue(function.crc16, out HashSet<string>? functionNames))
183+
_functionCache[function.crc16] = functionNames = new HashSet<string>();
184184

185185
functionNames.Add(name);
186186
}
@@ -210,8 +210,8 @@ protected override ScriptJump CreateJump(XseqJump jump, IBinaryReaderX? stringRe
210210
stringReader.BaseStream.Position = jump.nameOffset;
211211
name = stringReader.ReadCStringSJIS();
212212

213-
if (!_jumpCache.TryGetValue(jump.crc16, out IList<string>? jumpNames))
214-
_jumpCache[jump.crc16] = jumpNames = new List<string>();
213+
if (!_jumpCache.TryGetValue(jump.crc16, out HashSet<string>? jumpNames))
214+
_jumpCache[jump.crc16] = jumpNames = new HashSet<string>();
215215

216216
jumpNames.Add(name);
217217
}
@@ -256,7 +256,7 @@ protected override ScriptArgument CreateArgument(XseqArgument argument, int inst
256256

257257
if (argumentIndex != 0)
258258
{
259-
if (_functionCache.TryGetValue((ushort)argument.value, out IList<string>? names)
259+
if (_functionCache.TryGetValue((ushort)argument.value, out HashSet<string>? names)
260260
|| _jumpCache.TryGetValue((ushort)argument.value, out names))
261261
value = names.First();
262262
break;
@@ -265,7 +265,7 @@ protected override ScriptArgument CreateArgument(XseqArgument argument, int inst
265265
switch (instructionType)
266266
{
267267
case 20:
268-
if (_functionCache.TryGetValue((ushort)argument.value, out IList<string>? names))
268+
if (_functionCache.TryGetValue((ushort)argument.value, out HashSet<string>? names))
269269
value = names.First();
270270
break;
271271

XtractQuery/Logic.Domain.Level5/Logic.Domain.Level5/_Activator.cs

+12-10
Original file line numberDiff line numberDiff line change
@@ -57,19 +57,21 @@ public void Register(ICoCoKernel kernel)
5757
kernel.Register<IScriptWriterFactory, ScriptWriterFactory>(ActivationScope.Unique);
5858
kernel.Register<IScriptEntrySizeProviderFactory, ScriptEntrySizeProviderFactory>(ActivationScope.Unique);
5959

60-
kernel.Register<IXq32ScriptDecompressor, Xq32ScriptDecompressor>();
61-
kernel.Register<IXq32ScriptCompressor, Xq32ScriptCompressor>();
60+
kernel.Register<IXq32ScriptDecompressor, Xq32ScriptDecompressor>(ActivationScope.Unique);
61+
kernel.Register<IXq32ScriptCompressor, Xq32ScriptCompressor>(ActivationScope.Unique);
62+
kernel.Register<IXq32ScriptReader, Xq32ScriptReader>(ActivationScope.Unique);
63+
kernel.Register<IXq32ScriptWriter, Xq32ScriptWriter>(ActivationScope.Unique);
64+
kernel.Register<IXq32ScriptEntrySizeProvider, Xq32ScriptEntrySizeProvider>(ActivationScope.Unique);
65+
6266
kernel.Register<IXq32StringTable, Xq32StringTable>();
63-
kernel.Register<IXq32ScriptReader, Xq32ScriptReader>();
64-
kernel.Register<IXq32ScriptWriter, Xq32ScriptWriter>();
65-
kernel.Register<IXq32ScriptEntrySizeProvider, Xq32ScriptEntrySizeProvider>();
6667

67-
kernel.Register<IXseqScriptDecompressor, XseqScriptDecompressor>();
68-
kernel.Register<IXseqScriptCompressor, XseqScriptCompressor>();
68+
kernel.Register<IXseqScriptDecompressor, XseqScriptDecompressor>(ActivationScope.Unique);
69+
kernel.Register<IXseqScriptCompressor, XseqScriptCompressor>(ActivationScope.Unique);
70+
kernel.Register<IXseqScriptReader, XseqScriptReader>(ActivationScope.Unique);
71+
kernel.Register<IXseqScriptWriter, XseqScriptWriter>(ActivationScope.Unique);
72+
kernel.Register<IXseqScriptEntrySizeProvider, XseqScriptEntrySizeProvider>(ActivationScope.Unique);
73+
6974
kernel.Register<IXseqStringTable, XseqStringTable>();
70-
kernel.Register<IXseqScriptReader, XseqScriptReader>();
71-
kernel.Register<IXseqScriptWriter, XseqScriptWriter>();
72-
kernel.Register<IXseqScriptEntrySizeProvider, XseqScriptEntrySizeProvider>();
7375

7476
kernel.RegisterConfiguration<Level5Configuration>();
7577
}

0 commit comments

Comments
 (0)