world generator
#1
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?
Reply
Thanks given by:
#2
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.
Reply
Thanks given by:
#3
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.
Reply
Thanks given by:
#4
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).
Reply
Thanks given by:
#5
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
Reply
Thanks given by:
#6
Looks like the lighting generator is failing? Maybe it needs a block in the chunk to work?
Reply
Thanks given by:
#7
No this is probably because the height is not set properly.
Reply
Thanks given by:
#8
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.
Reply
Thanks given by:
#9
Sad 
I commented out the hook for chunk generating and tried only to generate a new world. After joining server crashes with that errorConfused
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.
Reply
Thanks given by:
#10
This is not related at all, but...


I think those Windows 8-esque error messages were a huge success!
Reply
Thanks given by:




Users browsing this thread: 10 Guest(s)