Closed WhyNotHugo closed 7 years ago
Does this happen consistently? Can you describe reproduction steps in more detail?
I can reproduce this consistently: it happens every single time. Steps are (sorry if this is stupidly verbose, but I just in case):
Selecting a pre-existing world has the same result.
I believe these dependencies are relevant:
I also tried deleting ~/.config/truecraft
.
I can reproduce. Will look into it.
I've been getting the same error as well. When I try to just run the client I got this as an output.
Unhandled Exception:
System.IndexOutOfRangeException: Index was outside the bounds of the array.
at TrueCraft.Client.Program.Main (System.String[] args) [0x0001c] in
I'm having the same issue with @hobarrera
same issue with @BearzRobotics i think this game is dead. too bad prob no fix.
Send me a patch and I'll merge it.
Ended up figuring this out by accident. The fast path for HandleChunkData seems to assume the chunk size when it may, for example, only have block IDs without metadata, light, or sky light. This fixes the crash for me, but I'm guessing the packet is supposed to have all of these things...?
diff --git a/TrueCraft.Client/Handlers/ChunkHandlers.cs b/TrueCraft.Client/Handlers/ChunkHandlers.cs
index 254299f..ede145a 100644
--- a/TrueCraft.Client/Handlers/ChunkHandlers.cs
+++ b/TrueCraft.Client/Handlers/ChunkHandlers.cs
@@ -52,16 +52,31 @@ namespace TrueCraft.Client.Handlers
&& packet.Height == Chunk.Height
&& packet.Depth == Chunk.Depth) // Fast path
{
+ // Chunk data offsets
+ int metadataOffset = chunk.Data.Length;
+ int lightOffset = metadataOffset + chunk.Metadata.Length;
+ int skylightOffset = lightOffset + chunk.BlockLight.Length;
+
// Block IDs
Buffer.BlockCopy(data, 0, chunk.Data, 0, chunk.Data.Length);
// Block metadata
- Buffer.BlockCopy(data, chunk.Data.Length, chunk.Metadata.Data, 0, chunk.Metadata.Data.Length);
+ if (metadataOffset < data.Length)
+ {
+ Buffer.BlockCopy(data, metadataOffset,
+ chunk.Metadata.Data, 0, chunk.Metadata.Data.Length);
+ }
// Block light
- Buffer.BlockCopy(data, chunk.Data.Length + chunk.Metadata.Data.Length,
- chunk.BlockLight.Data, 0, chunk.BlockLight.Data.Length);
+ if (lightOffset < data.Length)
+ {
+ Buffer.BlockCopy(data, lightOffset,
+ chunk.BlockLight.Data, 0, chunk.BlockLight.Data.Length);
+ }
// Sky light
- Buffer.BlockCopy(data, chunk.Data.Length + chunk.Metadata.Data.Length + chunk.BlockLight.Data.Length,
- chunk.SkyLight.Data, 0, chunk.SkyLight.Data.Length);
+ if (skylightOffset < data.Length)
+ {
+ Buffer.BlockCopy(data, skylightOffset,
+ chunk.SkyLight.Data, 0, chunk.SkyLight.Data.Length);
+ }
}
else // Slow path
{
Can you send this as a pull request instead of a diff thrown into a commit? You can email me a patch if you want, too.
Using latest commit still warrants the same effect. However, I want to note that this happens regardless of offline, or online mode and whether or not I load an already generated world. I am also compiling on VS 2017. Does the same with the precompiled binaries available on the website, with no errors.
Weird, on my side it runs fine.
Do you actually have the same error?
I'm running ArchLinux, and the latest master crashes when I try to start a game on a new world:
I'm on ArchLinux-amd64, with intel video.