Page 1 of 1

Block updating

PostPosted: Tue Oct 25, 2011 21:19
by dodomorandi
I'm quite in trouble when updating a block.
As you can see from my fork I'm trying to implement a "modular door", as suggested in a post. I need to use quite a lot the NodeMetadata class to define properties and let a single node handle every "child" (if a portion of a door is opened, for example, every node must be "opened"). To make the code run smooth I decided to let the doors handle pointers to parent and children. And that's the problem: when a TOCLIENT_BLOCKDATA command is sent, the new block is naturally deserialized. But the deserialization process is gradual, and the client crashes exactly when the MapNode and NodeMetadata information is partially saved in the MapBlock.
I thought to one solution (and maybe it could be THE solution, but I need your help) for this problem: I added the method MapSector::setBlock, to which a Mapblock object is passed (like MapSector::insertBlock) and sets (instead of inserting) the new node and then deleting the old one. The problem is... the client "flashes" when the block is completely rewritten.
So... what do you think I can do? Mutex-ing the client so a block is not rendered as new when it's rewritten? Making a new command to explicitly update Metadata? I'm trying to find a good solution, but I'm quite short of ideas.

I'll wait for your help!
-- dodomorandi

PostPosted: Fri Oct 28, 2011 15:26
by dodomorandi
Ok, there are some news.
I implemented a new server to client command in my fork. I called simply TOCLIENT_UPDATENODE and it's been developed to update little portion of map. TOCLIENT_BLOCKDATA is useful when a block has to be completely passed ex-novo to the client. But with this command you can specify a vector of absolute coordinates to update. The update is done either on MapNodes and NodeMetadatas, and it's done grouping coordinates by blocks, so it's passed the position of a block and a collection of block relative positions with serialized data. I'm testing this with doors, and it's so much faster than updating full blocks (with edges). And naturally I don't have the problem I was talking in the main post.

What do you think about this kind of approach? I think your opinion it's important, because I'm trying to develop minetest (like everyone, I think :-) ) in a developer-friendly way. Discussing and maybe changing point of view could be a good thing, for me, for everyone who want...

Thank you for everything!
-- dodomorandi

PostPosted: Fri Oct 28, 2011 15:38
by Staffs
You said "As you can see in my fork" Lol i didnt even know you had a fork do you have it in bitbucket if yes tell me the link :)

PostPosted: Mon Oct 31, 2011 01:05
by dodomorandi

PostPosted: Sun Nov 06, 2011 17:57
by Melkor
Thank you for adding this! :) the doors can be made of wood or iron, right? Can i suggest stone and cobble too? They can be usefull making secrets passage doors. Dont forget the hatches too :D