Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Publish

on: [push, pull_request]

env:
DOTNET_VERSION: "3.1.x" # The .NET SDK version to use

jobs:
test:
runs-on: ubuntu-latest

env:
ARTIFACT_BENCHMARK: "artifact/benchmark"

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Install dependencies
run: dotnet restore

# - name: Build
# run: |
# dotnet build PapyrusCs -c Release --no-restore

- name: Test
run: |
dotnet test --no-restore --verbosity normal

- name: Prepare artifacts
run: |
mkdir -p "${{ env.ARTIFACT_BENCHMARK }}"
cp "MapLoader.NUnitTests/bin/Debug/netcoreapp3.1/benchmark.png" "${{ env.ARTIFACT_BENCHMARK }}/benchmark.png"
cp "MapLoader.NUnitTests/bin/Debug/netcoreapp3.1/benchmark/Benchmark.png" "${{ env.ARTIFACT_BENCHMARK }}/benchmark-original.png"

- name: Upload benchmark
uses: actions/upload-artifact@v2
with:
name: "benchmark"
path: "${{ env.ARTIFACT_BENCHMARK }}/**/*"

publish:
runs-on: ubuntu-latest
strategy:
matrix:
runtime: [linux-x64, win-x64]

steps:
- uses: actions/checkout@v2
- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.DOTNET_VERSION }}

- name: Install dependencies
run: dotnet restore

# - name: Build
# run: |
# dotnet build PapyrusCs -c Release --no-restore

- name: Build ${{ matrix.runtime }}
run: |
dotnet publish PapyrusCs -c Release -o build/${{ matrix.runtime }} -r ${{ matrix.runtime }} --self-contained true

- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: "papyruscs-${{ matrix.runtime }}"
path: "build/${{ matrix.runtime }}/**/*"
44 changes: 29 additions & 15 deletions MapLoader.NUnitTests/OtherTests.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
Expand All @@ -8,6 +8,7 @@
using Maploader.Renderer.Heightmap;
using Maploader.Renderer.Imaging;
using Maploader.Renderer.Texture;
using Maploader.World;
using Microsoft.Extensions.ObjectPool;
using NUnit.Framework;
using PapyrusCs.Database;
Expand Down Expand Up @@ -165,16 +166,24 @@ public void BenchmarkRender()
{
var dut = new Maploader.World.World();
dut.Open(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "benchmark", "world", "db"));
int chunkRadius = 1;
int centerOffsetX = 1; //65;
int centerOffsetZ = 1; //65;
int XMin = -1, XMax = 3;
int ZMin = -1, ZMax = 4;
string filename = "benchmark.png";

RenderMap(chunkRadius, dut, centerOffsetX, centerOffsetZ, filename);
RenderMap(dut, filename, XMin, XMax, ZMin, ZMax);
}

private static void RenderMap(int chunkRadius, Maploader.World.World dut, int centerOffsetX,
int centerOffsetZ, string filename)
{
int XMin = centerOffsetX - chunkRadius, XMax = centerOffsetX + chunkRadius;
int ZMin = centerOffsetZ - chunkRadius, ZMax = centerOffsetZ + chunkRadius;

RenderMap(dut, filename, XMin, XMax, ZMin, ZMax);
}

private static void RenderMap(Maploader.World.World dut, string filename,
int XMin, int XMax, int ZMin, int ZMax)
{
var json = File.ReadAllText(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"textures",
"terrain_texture.json"));
Expand All @@ -185,20 +194,25 @@ private static void RenderMap(int chunkRadius, Maploader.World.World dut, int ce
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "textures"), g);
finder.Debug = false;

var b = g.CreateEmptyImage(16 * 16 * (2 * chunkRadius + 1), 16 * 16 * (2 * chunkRadius + 1));
var b = g.CreateEmptyImage(16 * 16 * (XMax - XMin + 1), 16 * 16 * (ZMax - ZMin + 1));

var render = new ChunkRenderer<Bitmap>(finder, g, new RenderSettings() { YMax = 40 });

var render = new ChunkRenderer<Bitmap>(finder, g, new RenderSettings() {YMax = 40});
var keysByXZ = dut.GetDimension(0)
.Select(x => new LevelDbWorldKey2(x))
.Where(c => c.X <= XMax && c.X >= XMin && c.Z <= ZMax && c.Z >= ZMin)
.GroupBy(x => x.XZ);
var chunkKeys = keysByXZ.Select(chunkGroup => new GroupedChunkSubKeys(chunkGroup));
var chunkDatas = chunkKeys.Select(dut.GetChunkData);

//Parallel.For(-chunkRadius, chunkRadius + 1,new ParallelOptions(){MaxDegreeOfParallelism = 8} , dx =>
for (int dz = -chunkRadius; dz <= chunkRadius; dz++)
foreach (var chunkData in chunkDatas)
{
for (int dx = -chunkRadius; dx <= chunkRadius; dx++)
var c = dut.GetChunk(chunkData.X, chunkData.Z, chunkData);
if (c != null)
{
var c = dut.GetChunk(dx + centerOffsetX, dz + centerOffsetZ);
if (c != null)
{
render.RenderChunk(b, c, (chunkRadius + dx) * 256, (chunkRadius + dz) * 256);
}
int dx = chunkData.X - XMin;
int dz = chunkData.Z - ZMin;
render.RenderChunk(b, c, dx * 256, dz * 256);
}
}

Expand Down
Binary file modified MapLoader.NUnitTests/benchmark/Benchmark.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file removed MapLoader.NUnitTests/benchmark/world/db/001497.ldb
Binary file not shown.
Binary file removed MapLoader.NUnitTests/benchmark/world/db/001499.ldb
Binary file not shown.
Binary file removed MapLoader.NUnitTests/benchmark/world/db/001500.log
Binary file not shown.
2 changes: 1 addition & 1 deletion MapLoader.NUnitTests/benchmark/world/db/CURRENT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
MANIFEST-001498
MANIFEST-000103
Empty file.
Binary file not shown.
Binary file removed MapLoader.NUnitTests/benchmark/world/db/MANIFEST-001498
Binary file not shown.
Binary file modified MapLoader.NUnitTests/benchmark/world/level.dat
Binary file not shown.
Binary file modified MapLoader.NUnitTests/benchmark/world/level.dat_old
Binary file not shown.
2 changes: 1 addition & 1 deletion MapLoader.NUnitTests/benchmark/world/levelname.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Benchmark New
1.19.0 Test
Binary file modified MapLoader.NUnitTests/benchmark/world/world_icon.jpeg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions Maploader/World/World.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public Chunk GetChunk(int x, int z, ChunkData data)
return c;
}

[Obsolete("Use GetChunk(int x, int z, ChunkData data) instead")]
public Chunk GetChunk(int x, int z)
{
bool haveData = false;
Expand All @@ -130,14 +131,14 @@ public Chunk GetChunk(int x, int z)

var key = CreateKey(x, z);

for (byte subChunkIdx = 0; subChunkIdx < 15; subChunkIdx++)
for (sbyte subChunkIdx = -4; subChunkIdx < 20; subChunkIdx++)
{
key[9] = subChunkIdx;
key[9] = (byte)subChunkIdx;
UIntPtr length;
var data = db.Get(key, out length);
if (data != null)
{
subChunks[subChunkIdx] = data;
subChunks[(byte)subChunkIdx] = data;
haveData = true;
}
}
Expand Down
3 changes: 1 addition & 2 deletions readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
Chat: [![Discord](https://img.shields.io/discord/569841820092203011.svg?logo=discord&logoColor=white)](https://discord.gg/J2sBaXa) <br>
Windows: [![Build status](https://ci.appveyor.com/api/projects/status/tfspbbi72bx73qg8?svg=true)](https://ci.appveyor.com/project/mjungnickel18/papyruscs) <br>
Linux: [![Build status](https://ci.appveyor.com/api/projects/status/xo9ew31l49hayjcm?svg=true)](https://ci.appveyor.com/project/mjungnickel18/papyruscs-ytqjm) <br>
Build: [![GitHub Workflow Status](https://img.shields.io/github/workflow/status/papyrus-mc/papyruscs/publish?logo=github)](https://github.com/papyrus-mc/papyruscs/actions/workflows/publish.yml?query=branch%3Amaster) <br>

# Papyrus

Expand Down