mirror of
https://github.com/haven1433/HexManiacAdvance.git
synced 2026-10-02 05:06:35 -05:00
bugfix / performance fix
This commit is contained in:
@@ -754,6 +754,32 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||
}
|
||||
}
|
||||
|
||||
public void RepeatBlock(ModelDelta token, int block, int collision, int x, int y, int w, int h) {
|
||||
var layout = GetLayout();
|
||||
var (width, height) = (layout.GetValue("width"), layout.GetValue("height"));
|
||||
var start = layout.GetAddress("blockmap");
|
||||
int changeCount = 0;
|
||||
for (int xx = 0; xx < w; xx++) {
|
||||
for (int yy = 0; yy < h; yy++) {
|
||||
if (x + xx < 0 || y + yy < 0 || x + xx >= width || y + yy >= height) continue;
|
||||
var address = start + ((yy + y) * width + xx + x) * 2;
|
||||
// var block = blockValues[xx % blockValues.GetLength(0), yy % blockValues.GetLength(1)];
|
||||
var blockValue = model.ReadMultiByteValue(address, 2);
|
||||
var originalBlockValue = blockValue;
|
||||
if (block >= 0) blockValue = (blockValue & 0xFC00) + block;
|
||||
if (collision >= 0) blockValue = (blockValue & 0x3FF) + (collision << 10);
|
||||
if (blockValue != originalBlockValue) {
|
||||
model.WriteMultiByteValue(address, 2, token, blockValue);
|
||||
changeCount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (changeCount > 0) {
|
||||
pixelData = null;
|
||||
NotifyPropertyChanged(nameof(PixelData));
|
||||
}
|
||||
}
|
||||
|
||||
public void RepeatBlocks(ModelDelta token, int[,] blockValues, int x, int y, int w, int h) {
|
||||
var layout = GetLayout();
|
||||
var (width, height) = (layout.GetValue("width"), layout.GetValue("height"));
|
||||
|
||||
@@ -714,11 +714,7 @@ namespace HavenSoft.HexManiac.Core.ViewModels.Map {
|
||||
var (width, height) = (right - left + 1, bottom - top + 1);
|
||||
|
||||
if (tilesToDraw == null) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
for (int x = 0; x < width; x++) {
|
||||
primaryMap.DrawBlock(history.CurrentChange, drawBlockIndex, collisionIndex, left + x, top + y);
|
||||
}
|
||||
}
|
||||
primaryMap.RepeatBlock(history.CurrentChange, drawBlockIndex, collisionIndex, left, top, width, height);
|
||||
} else {
|
||||
primaryMap.RepeatBlocks(history.CurrentChange, tilesToDraw, left, top, width, height);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user