Skip to content

Commit 99297a8

Browse files
JhobeanAsYlum-
andauthored
Merge Master to Resistance (#1)
* Update animation list layout. * Update animation editor layout. * Update change log and version. * Fix mul operations when verdata is present. * Avoid crashes when using "Export all". Update gump file names when exporting. * Update packages. * Update change log and version. * Update packages. * Fix reading older artidx.mul files. * Update year in project files. * Update change log and version. * Update packages. * Update workflows. --------- Co-authored-by: AsY!um- <377468+AsYlum-@users.noreply.github.com>
1 parent e4616c4 commit 99297a8

File tree

23 files changed

+1449
-1321
lines changed

23 files changed

+1449
-1321
lines changed

.github/workflows/build-and-release.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ jobs:
3535
fetch-depth: 0
3636

3737
- name: Install .NET Core
38-
uses: actions/setup-dotnet@v4.3.0
38+
uses: actions/setup-dotnet@v4.3.1
3939
with:
4040
dotnet-version: 8.0.x
4141

@@ -45,7 +45,7 @@ jobs:
4545
Configuration: ${{ matrix.configuration }}
4646

4747
- name: Upload build artifacts
48-
uses: actions/upload-artifact@v4.6.1
48+
uses: actions/upload-artifact@v4.6.2
4949
with:
5050
name: ${{ env.Asset_Name }}.zip
5151
path: ./UOFiddler/bin/Release/
@@ -65,7 +65,7 @@ jobs:
6565

6666
steps:
6767
- name: Download artifacts
68-
uses: actions/download-artifact@v4.1.8
68+
uses: actions/download-artifact@v4.3.0
6969
with:
7070
name: ${{ env.Asset_Name }}.zip
7171
path: ./${{ env.Asset_Name }}/
@@ -74,7 +74,7 @@ jobs:
7474
run: 7z a -tzip ${{ env.Asset_Name }}.zip './${{ env.Asset_Name }}'
7575

7676
- name: Create release
77-
uses: softprops/action-gh-release@v2.2.1
77+
uses: softprops/action-gh-release@v2.2.2
7878
with:
7979
name: UOFiddler ${{ github.ref_name }}
8080
generate_release_notes: true

.github/workflows/build-pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
fetch-depth: 1
3333

3434
- name: Install .NET Core
35-
uses: actions/setup-dotnet@v4.3.0
35+
uses: actions/setup-dotnet@v4.3.1
3636
with:
3737
dotnet-version: 8.0.x
3838

Ultima/FileIndex.cs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ public Stream Seek(int index, out int length, out int extra, out bool patched)
225225

226226
IEntry e = FileAccessor.GetEntry(index);
227227

228-
if (e.Lookup < 0)
228+
if (e.Lookup < 0 || (e.Lookup > 0 && e.Length == -1))
229229
{
230230
length = extra = 0;
231231
patched = false;
@@ -274,40 +274,47 @@ public Stream Seek(int index, out int length, out int extra, out bool patched)
274274
return FileAccessor.Stream;
275275
}
276276

277-
public Stream Seek(int index, ref IEntry entry)
277+
public Stream Seek(int index, ref IEntry entry, out bool patched)
278278
{
279279
if (FileAccessor is null)
280280
{
281+
patched = false;
281282
return null;
282283
}
283284

284285
if (index < 0 || index >= FileAccessor.IndexLength)
285286
{
287+
patched = false;
286288
return null;
287289
}
288290

289291
IEntry e = FileAccessor.GetEntry(index);
290292

291293
if (e.Lookup < 0)
292294
{
295+
patched = false;
293296
return null;
294297
}
295298

296-
if (e.Length < 0)
299+
var length = e.Length & 0x7FFFFFFF;
300+
if (length < 0)
297301
{
302+
patched = false;
298303
return null;
299304
}
300305

301306
entry = e;
302307

303308
if ((e.Length & (1 << 31)) != 0)
304309
{
310+
patched = true;
305311
Verdata.Seek(e.Lookup);
306312
return Verdata.Stream;
307313
}
308314

309315
if (e.Length < 0)
310316
{
317+
patched = false;
311318
return null;
312319
}
313320

@@ -318,14 +325,18 @@ public Stream Seek(int index, ref IEntry entry)
318325

319326
if (FileAccessor.Stream == null)
320327
{
328+
patched = false;
321329
return null;
322330
}
323331

324332
if (FileAccessor.Stream.Length < e.Lookup)
325333
{
334+
patched = false;
326335
return null;
327336
}
328337

338+
patched = false;
339+
329340
FileAccessor.Stream.Seek(e.Lookup, SeekOrigin.Begin);
330341
return FileAccessor.Stream;
331342
}

Ultima/Gumps.cs

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public static byte[] GetRawGump(int index, out int width, out int height)
133133
height = -1;
134134

135135
IEntry entry = null;
136-
Stream stream = _fileIndex.Seek(index, ref entry);
136+
Stream stream = _fileIndex.Seek(index, ref entry, out bool patched);
137137
if (stream == null || entry == null)
138138
{
139139
return null;
@@ -147,6 +147,11 @@ public static byte[] GetRawGump(int index, out int width, out int height)
147147
// Compressed UOPs
148148
if (entry.Flag >= CompressionFlag.Zlib)
149149
{
150+
if (patched)
151+
{
152+
throw new InvalidOperationException("Verdata.mul is not supported for compressed UOP");
153+
}
154+
150155
if (_streamBuffer == null || _streamBuffer.Length < entry.Length)
151156
{
152157
_streamBuffer = new byte[entry.Length];
@@ -193,8 +198,14 @@ public static byte[] GetRawGump(int index, out int width, out int height)
193198
return _streamBuffer;
194199
}
195200

196-
var buffer = new byte[entry.Length];
197-
stream.Read(buffer, 0, entry.Length);
201+
var length = entry.Length;
202+
if (patched)
203+
{
204+
length = entry.Length & 0x7FFFFFFF;
205+
}
206+
207+
var buffer = new byte[length];
208+
stream.ReadExactly(buffer, 0, length);
198209
stream.Close();
199210

200211
return buffer;
@@ -208,6 +219,7 @@ public static byte[] GetRawGump(int index, out int width, out int height)
208219
/// <param name="onlyHueGrayPixels"></param>
209220
/// <param name="patched"></param>
210221
/// <returns></returns>
222+
// TODO: Currently unused and may be broken because of recent UOP changes. Needs verdata `patched` checks and compression handling
211223
public static unsafe Bitmap GetGump(int index, Hue hue, bool onlyHueGrayPixels, out bool patched)
212224
{
213225
Stream stream = _fileIndex.Seek(index, out int length, out int extra, out patched);
@@ -405,7 +417,7 @@ public static unsafe Bitmap GetGump(int index, out bool patched)
405417
}
406418

407419
IEntry entry = null;
408-
Stream stream = _fileIndex.Seek(index, ref entry);
420+
Stream stream = _fileIndex.Seek(index, ref entry, out patched);
409421
if (stream == null || entry == null)
410422
{
411423
return null;
@@ -422,12 +434,18 @@ public static unsafe Bitmap GetGump(int index, out bool patched)
422434
_patched[index] = true;
423435
}
424436

425-
if (_streamBuffer == null || _streamBuffer.Length < entry.Length)
437+
var length = entry.Length;
438+
if (patched)
439+
{
440+
length = entry.Length & 0x7FFFFFFF;
441+
}
442+
443+
if (_streamBuffer == null || _streamBuffer.Length < length)
426444
{
427-
_streamBuffer = new byte[entry.Length];
445+
_streamBuffer = new byte[length];
428446
}
429447

430-
stream.Read(_streamBuffer, 0, entry.Length);
448+
stream.Read(_streamBuffer, 0, length);
431449

432450
uint width = (uint)entry.Extra1;
433451
uint height = (uint)entry.Extra2;
@@ -544,8 +562,8 @@ public static unsafe void Save(string path)
544562
if ((bmp == null) || (_removed[index]))
545563
{
546564
binidx.Write(-1); // lookup
547-
binidx.Write(-1); // length
548-
binidx.Write(-1); // extra
565+
binidx.Write(0); // length
566+
binidx.Write(0); // extra
549567
}
550568
else
551569
{

0 commit comments

Comments
 (0)