Posts: 17
Threads: 6
Joined: Apr 2015
Thanks: 6
Given 2 thank(s) in 2 post(s)
05-07-2015, 10:12 AM
(This post was last modified: 05-08-2015, 12:12 PM by NathanFlurry.)
Hello,
I'm trying to create a "pseudo world", for lack of a better term, in which multiple worlds are created, yet all of them read from one world file.
From what I can tell, there is no way to hook into sending a chunk to a player, so using it alongside CreateAndInitializeWorld would be worthless.
If anyone has a solution to this, that world be wonderful, as it is essential to something I am attempting to do.
Thanks,
Nathan
P.S. I do understand that a distributed MCServer will not be implemented, but I believe this is a bit different.
P.P.S. I don't need to write to the world, only read the data and send it to the players.
Posts: 783
Threads: 12
Joined: Jan 2014
Thanks: 2
Given 73 thank(s) in 61 post(s)
It would be useful to have a bit more detail about what you're doing. At the moment the only hook we have that's at all relevant is HOOK_CHUNK_GENERATING, but I suspect thats not what you want. Are you trying to load multiple different chunks a the same location? Because that would involve significant modification to how we store chunks, but it might be achievable.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
I'm not sure if I understand what you want to do exactly, but I think this might help: It is possible to create multiple worlds that share the world data (the .MCA files), although it is highly advisable that only one such world writes the data, the others should only read. This is exactly what the world storage schema Forgetful does - it loads data from the disk, but doesn't save. This way you can have a world which is read-write and only admins are allowed there, and another world(s) that is read-only and reads the data from the first world. In order to set this up, you need to be able to do hardlinks in your filesystem, though, to point the second world's "region" folder to the first world's "region" folder.
Still, the set of worlds is static. There is an experimental function CreateAndInitializeWorld(), but its use is dangerous as it quite often causes a deadlock in the server. And there's no way to delete a world while the server is running - the API just doesn't support that model, it is expected that a cWorld object that you get is valid for the lifetime of the server.
Posts: 783
Threads: 12
Joined: Jan 2014
Thanks: 2
Given 73 thank(s) in 61 post(s)
A safe way of creating and deleting worlds on the fly is probably the best way of doing it under MCServer's structure. I can't rember what the deadlocks we had with CreateAndInitialize were, but fixing them would be simpler than hooking chunk sending to do this.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
Yes, but it will be a lot of work and a rather big change in the API. Again, it would need the object lifetime rewrite; right now plugins expect all cWorld instances to be valid throughout their life.
Posts: 783
Threads: 12
Joined: Jan 2014
Thanks: 2
Given 73 thank(s) in 61 post(s)
Its still simpler than reimplementing half the server core which you would have to do to get this to work by hooking into chunk sending.
Posts: 4,628
Threads: 115
Joined: Dec 2011
Thanks: 693
Given 494 thank(s) in 423 post(s)
And if it's done now, we might have around 10 plugins that need a change, but if it's done later who knows how many plugins have to change.
Posts: 6,485
Threads: 176
Joined: Jan 2012
Thanks: 131
Given 1075 thank(s) in 852 post(s)
I'm just saying even the lifetime change is such a huge change that I don't think it's gonna happen in any foreseeable future. Basically it would mean throwing ToLua out and implementing all bindings manually.