discord bugfixes

This commit is contained in:
haven1433 2025-11-27 23:51:36 -06:00
parent 1937ea2684
commit b96761cf17
5 changed files with 8 additions and 4 deletions

View File

@ -6,7 +6,6 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Xml.Linq;
namespace HavenSoft.HexManiac.Core.Models.Map {
@ -99,7 +98,7 @@ namespace HavenSoft.HexManiac.Core.Models.Map {
public BlockmapRun Run => Model.GetNextRun(Start) as BlockmapRun;
public BlockCell this[int x, int y] {
get {
if (Start == Pointer.NULL) return null;
if (Start < 0) return null;
var data = Model.ReadMultiByteValue(Start + (y * Width + x) * 2, 2);
return new(data & 0x3FF, data >> 10);
}

View File

@ -11,6 +11,7 @@ namespace HavenSoft.HexManiac.Core.Models.Runs.Sprites {
public override int Pages {
get {
if (Start + 4 > Model.Count) return 1;
var length = Model.ReadMultiByteValue(Start + 1, 3);
var paletteLength = (int)Math.Pow(2, PaletteFormat.Bits) * 2;
return length / paletteLength;

View File

@ -40,7 +40,9 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Images {
// copy one row at a time, to account for gaps
var start = Math.Max(x, 0);
var end = Math.Min(x + foreground.PixelWidth, PixelWidth);
Array.Copy(foreground.PixelData, foreground.PixelWidth * yy + start - x, PixelData, PixelWidth * (y + yy) + x, end - start);
if (end > start) {
Array.Copy(foreground.PixelData, foreground.PixelWidth * yy + start - x, PixelData, PixelWidth * (y + yy) + x, end - start);
}
} else {
// go through each pixel to look for transparency
for (int xx = 0; xx < foreground.PixelWidth; xx++) {

View File

@ -2359,6 +2359,8 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
var canvas = new CanvasPixelViewModel(width * 16, height * 16);
for (int y = 0; y < height; y++) {
for (int x = 0; x < width; x++) {
var address = start + (y * width + x);
if (address + 2 >= model.Count || address < 0) continue;
var data = model.ReadMultiByteValue(start + (y * width + x) * 2, 2);
data &= 0x3FF;
lock (blockRenders) {

View File

@ -263,7 +263,7 @@ namespace HavenSoft.HexManiac.WPF.Controls {
public async void UpdateSource() {
var vm = ViewModel;
if (vm == null) return;
if (vm == null || vm.PixelWidth < 0 || vm.PixelHeight < 0) return;
short[] pixels;
if (vm is not BlockMapViewModel) {
pixels = vm.PixelData;