Posts: 513
Threads: 10
Joined: May 2014
Thanks: 138
Given 89 thank(s) in 75 post(s)
Hello!
I have looked and played around with the chunk generation. For first I tried to generate a air world with that code.
Code: -- Add hook for chunk generation in function Initialize
cPluginManager:AddHook(cPluginManager.HOOK_CHUNK_GENERATING, AirGenerator)
-- Code for the event
function AirGenerator(World, ChunkX, ChunkZ, ChunkDesc)
if (World:GetName() == "airworld") then
FillBlocks(ChunkDesc)
end
end
function FillBlocks(ChunkDesc)
ChunkDesc:FillBlocks(0, 0) -- air blocks
ChunkDesc:SetUseDefaultBiomes(false)
ChunkDesc:SetUseDefaultHeight(false)
ChunkDesc:SetUseDefaultComposition(false)
-- ChunkDesc:SetUseDefaultStructures(false) deprecated?
ChunkDesc:SetUseDefaultFinish(false)
end
I tried to use that and get this error in the console
"[14:02:13] cChunk::UnboundedRelGetBlock: requesting a block with a_RelY out of range: -1"
Is a custom world generator supported or not?
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1074 thank(s) in 852 post(s)
05-04-2014, 10:31 PM
(This post was last modified: 05-04-2014, 10:34 PM by xoft.)
Hello,
welcome to the forum.
Please next time paste code in [ shcode=lua ] [ /shcode ] tags - that will syntax-highlight the code and will expand the box, so that no scrollbar is needed.
As for the error you're seeing, it looks as a bug in the server. Are you using a debug build or a release build of MCServer? (Debug build is something you build yourself, includes more checks). I think the debug build should terminate on encountering this error; if you run the server under a debugger, you will be able to see where exactly it happened, and what the callstack was. This would help us hunt the bug down.
Can you try changing your FillBlocks() function to temporarily add a layer of solid blocks somewhere? Like this:
function FillBlocks(ChunkDesc)
ChunkDesc:FillBlocks(E_BLOCK_AIR, 0)
ChunkDesc:FillRelCuboid(0, 15, 60, 60, 0, 15, E_BLOCK_STONE, 0) -- Fill 1 layer with stone, at height 60
ChunkDesc:SetUseDefaultBiomes(false)
ChunkDesc:SetUseDefaultHeight(false)
ChunkDesc:SetUseDefaultComposition(false)
ChunkDesc:SetUseDefaultFinish(false)
end
As for the DefaultStructures, there has been a change recently in the generator, it no longer distinguishes between a structure and a finisher, so the function is "deprecated" - it is still in the API but does nothing except for a log message. You don't need to use it at all.
Custom generators are completely supported, as a proof you can see the Gallery server, it uses a custom generator to fill the galleries with the templates for the areas.
Posts: 513
Threads: 10
Joined: May 2014
Thanks: 138
Given 89 thank(s) in 75 post(s)
05-04-2014, 11:39 PM
(This post was last modified: 05-04-2014, 11:56 PM by Seadragon91.)
I cloned the git repository. Okay tested your code and that crashed the server with this error:
"Unhandled exception at 0x013dd226 in MCServer.exe: 0xC0000005: Access violation reading at position 0x00000033 ."
I wasn't able to start the project in debug mode that crashes at startup with error "Assertion failed: 0, file ChunkStay.cpp, line 34"
Edit: Tested the build from the website, crashes after teleporting to the world with an access violation.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1074 thank(s) in 852 post(s)
I'm afraid I can't replicate this. I tried your initial example (had to modify it slightly so that the plugin loads - added the Initialize function and moved the hook registration to the bottom) and it works okay for me.
If it crashes for you in the executable from the nightbuild website, could you help me out? There's a guide on how to report crashes, https://forum.cuberite.org/showthread.php?tid=400 , follow that to get the crashdump.
Alternatively, if it crashes in your MSVC debugger, post the contents of the Call Stack window when it breaks into the debugger (you can Shift-select all the rows and copy and paste them).
Posts: 513
Threads: 10
Joined: May 2014
Thanks: 138
Given 89 thank(s) in 75 post(s)
Okay, tested that now under linux. Cloned source with git from github and compiled it without any problems.
Created a release version of the server. Added my plugin, started the server and joined the world. Then the console get spammed with this error.
Code: [20:51:23] UnboundedRelGetBlock: requesting a block with a_RelY out of range: -1
If I try to start the debug version of the server, it stops with that error.
Code: [7fe29337d740|20:58:34] Assertion failed: m_World == NULL, file /home/lukas/cpp/MCServer/src/LightingThread.cpp, line 93
MCServer_debug: /home/lukas/cpp/MCServer/src/LightingThread.cpp:93: bool cLightingThread::Start(cWorld*): Assertion `0' failed.
Aborted
Here's the source of the plugin, do I make a very big mistake?
PLUGIN = nil
function Initialize(Plugin)
Plugin:SetName("TestPlugin")
Plugin:SetVersion(1)
PLUGIN = Plugin
LOG("Initialised " .. Plugin:GetName() .. " v." .. Plugin:GetVersion())
-- create the world
CreateWorld()
-- Hooks
cPluginManager:AddHook(cPluginManager.HOOK_CHUNK_GENERATING, AirGenerator)
-- Command Bindings
cPluginManager.BindCommand("/checkworld", "testplugin.checkworld", CheckWorld, " - Check if world exists")
cPluginManager.BindCommand("/teleportto", "testplugin.teleportto", TeleportTo, " - Teleport to world")
return true
end
function OnDisable()
LOG(PLUGIN:GetName() .. " is shutting down...")
end
function CheckWorld(Split, Player)
if (#Split ~=2) then
Player:SendMessage("Usage: /checkworld <worldname>")
return true
end
if (cRoot:Get():GetWorld(Split[2]) == Nil) then
Player:SendMessage("No world exists with that name.")
return true
end
Player:SendMessage("The world exists.")
return true
end
function TeleportTo(Split, Player)
if (#Split ~=2) then
Player:SendMessage("Usage: /teleportto <worldname>")
return true
end
if (cRoot:Get():GetWorld(Split[2]) == Nil) then
Player:SendMessage("No world exists with that name.")
return true
end
Player:MoveToWorld(Split[2])
Player:TeleportToCoords(0, 100, 0)
Player:SendMessage("Teleported you...")
return true
end
function CreateWorld()
cRoot:Get():CreateAndInitializeWorld("airworld")
end
function AirGenerator(a_World, a_ChunkX, a_ChunkZ, a_ChunkDesc)
if (a_World:GetName() == "airworld") then
FillBlocks(a_ChunkDesc)
end
end
function FillBlocks(a_ChunkDesc)
a_ChunkDesc:FillBlocks(E_BLOCK_AIR, 0)
a_ChunkDesc:FillRelCuboid(0, 15, 60, 60, 0, 15, E_BLOCK_STONE, 0) -- Fill 1 layer with stone, at height 60
a_ChunkDesc:SetUseDefaultBiomes(false)
a_ChunkDesc:SetUseDefaultHeight(false)
a_ChunkDesc:SetUseDefaultComposition(false)
a_ChunkDesc:SetUseDefaultFinish(false)
end
Posts: 1,469
Threads: 57
Joined: Jul 2012
Thanks: 66
Given 127 thank(s) in 108 post(s)
Looks like the lighting generator is failing? Maybe it needs a block in the chunk to work?
Posts: 4,628
Threads: 115
Joined: Dec 2011
Thanks: 693
Given 494 thank(s) in 423 post(s)
No this is probably because the height is not set properly.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1074 thank(s) in 852 post(s)
I *think* it might be because your plugin is creating and initializing a world in its Initialize() function, that's too early. I'll test later today and get back with the results.
Posts: 513
Threads: 10
Joined: May 2014
Thanks: 138
Given 89 thank(s) in 75 post(s)
05-05-2014, 03:29 PM
(This post was last modified: 05-05-2014, 03:31 PM by Seadragon91.)
I commented out the hook for chunk generating and tried only to generate a new world. After joining server crashes with that error
Code: [07:18:09] D: | MCServer has encountered an error and needs to close
[07:18:09] Details | SIGSEGV: Segmentation fault
Without my plugin the server starts fine in debug mode.
Anyone have an idea, how I can provide more informations?
Edit: Didn't see your post will try to create a world trough a command.
Posts: 952
Threads: 16
Joined: May 2013
Thanks: 66
Given 105 thank(s) in 89 post(s)
This is not related at all, but...
I think those Windows 8-esque error messages were a huge success!
|