Page 1 of 1

Block loading

PostPosted: Thu Dec 13, 2012 17:37
by Nore
Is it possible to add a parameter to change the distance where the blocks get unloaded ? Or even to add a node that forces block loading ?

PostPosted: Thu Dec 13, 2012 17:43
by PilzAdam
You cant add a node that forces update.
But there are some settings in minetest.conf, something like client_unload_unused_data_timeout or something like this.

PostPosted: Thu Dec 13, 2012 18:03
by Nore
A node that forces update could not even be done in the C++ code ? (with a file to know where those block are)

PostPosted: Thu Dec 13, 2012 18:37
by thetoon
There should be a way, but it's more like a hack than a real solution. Haven't tested it yet, for I'm not on my computer. In environment.cpp, from line 990, you got :

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
               
                core::list<v3s16> players_blockpos;
                for(core::list<Player*>::Iterator
                                i = m_players.begin();
                                i != m_players.end(); i++)
                {
                        Player *player = *i;
                        // Ignore disconnected players
                        if(player->peer_id == 0)
                                continue;
                        v3s16 blockpos = getNodeBlockPos(
                                        floatToInt(player->getPosition(), BS));
                        players_blockpos.push_back(blockpos);
                }


players_blockpos is a list containing players' positions (populated in the following loop). Later in the code, elements in that list are used as centers of perimeters within which blocks are considered active.

If, for any reason, coordinates where added to that list without being any player's position (say, from a table the map's sqlite file), I bet the perimeter (within active_block_range radius) around those coordinates would be considered active nonetheless.

What do you think?

PostPosted: Thu Dec 13, 2012 18:43
by Nore
It could work, but as I am no C coder (more like a Python coder), I don't know if it would work, and if it would not have any secondary effect on the rest.

PostPosted: Thu Dec 13, 2012 19:04
by OmniStudent
thetoon wrote:There should be a way, but it's more like a hack than a real solution. Haven't tested it yet, for I'm not on my computer. In environment.cpp, from line 990, you got :

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
               
                core::list<v3s16> players_blockpos;
                for(core::list<Player*>::Iterator
                                i = m_players.begin();
                                i != m_players.end(); i++)
                {
                        Player *player = *i;
                        // Ignore disconnected players
                        if(player->peer_id == 0)
                                continue;
                        v3s16 blockpos = getNodeBlockPos(
                                        floatToInt(player->getPosition(), BS));
                        players_blockpos.push_back(blockpos);
                }


players_blockpos is a list containing players' positions (populated in the following loop). Later in the code, elements in that list are used as centers of perimeters within which blocks are considered active.

If, for any reason, coordinates where added to that list without being any player's position (say, from a table the map's sqlite file), I bet the perimeter (within active_block_range radius) around those coordinates would be considered active nonetheless.

What do you think?


Is this executed on the server or the client?

PostPosted: Thu Dec 13, 2012 19:05
by rubenwardy
OmniStudent wrote:
thetoon wrote:There should be a way, but it's more like a hack than a real solution. Haven't tested it yet, for I'm not on my computer. In environment.cpp, from line 990, you got :

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
               
                core::list<v3s16> players_blockpos;
                for(core::list<Player*>::Iterator
                                i = m_players.begin();
                                i != m_players.end(); i++)
                {
                        Player *player = *i;
                        // Ignore disconnected players
                        if(player->peer_id == 0)
                                continue;
                        v3s16 blockpos = getNodeBlockPos(
                                        floatToInt(player->getPosition(), BS));
                        players_blockpos.push_back(blockpos);
                }


players_blockpos is a list containing players' positions (populated in the following loop). Later in the code, elements in that list are used as centers of perimeters within which blocks are considered active.

If, for any reason, coordinates where added to that list without being any player's position (say, from a table the map's sqlite file), I bet the perimeter (within active_block_range radius) around those coordinates would be considered active nonetheless.

What do you think?


Is this executed on the server or the client?

server

PostPosted: Wed Jan 16, 2013 15:18
by Nore
Would it be possible to add a function to do that to the modding API?

PostPosted: Thu Feb 14, 2013 13:10
by andrea65751
hi..
no it is not possible.

PostPosted: Fri Feb 22, 2013 00:59
by prestidigitator
I'd be more interested in an API function that forces a one-time load of a chunk with explicitly provided coordinates, as if a player had just visited (though not extending to surrounding chunks). I think this would be very useful for mods that need to know what's in some neighboring region of space, and consider it high enough priority not to just fall back to some default behavior if they get "ignore" nodes.

PostPosted: Fri Feb 22, 2013 01:33
by lkjoel
prestidigitator wrote:I'd be more interested in an API function that forces a one-time load of a chunk with explicitly provided coordinates, as if a player had just visited (though not extending to surrounding chunks). I think this would be very useful for mods that need to know what's in some neighboring region of space, and consider it high enough priority not to just fall back to some default behavior if they get "ignore" nodes.

+10000000000

I'd do anything to have that, even help making it, if that's needed!!!

PostPosted: Fri Feb 22, 2013 10:05
by paramat
prestidigitator wrote:I'd be more interested in an API function that forces a one-time load of a chunk with explicitly provided coordinates, as if a player had just visited (though not extending to surrounding chunks). I think this would be very useful for mods that need to know what's in some neighboring region of space, and consider it high enough priority not to just fall back to some default behavior if they get "ignore" nodes.

Yep i have some mods that need exactly this function (landup, moonlet).

Apparently this may have just been added, see this pull request https://github.com/celeron55/minetest/pull/446
I don't understand the technical language here so i'm not sure if it has gone ahead or not.

PostPosted: Fri Feb 22, 2013 10:48
by prestidigitator
paramat wrote:
prestidigitator wrote:I'd be more interested in an API function that forces a one-time load of a chunk with explicitly provided coordinates, as if a player had just visited (though not extending to surrounding chunks). I think this would be very useful for mods that need to know what's in some neighboring region of space, and consider it high enough priority not to just fall back to some default behavior if they get "ignore" nodes.

Yep i have some mods that need exactly this function (landup, moonlet).

Apparently this may have just been added, see this pull request https://github.com/celeron55/minetest/pull/446
I don't understand the technical language here so i'm not sure if it has gone ahead or not.

Awesome! Yes, it looks like it may be included. So to do a one-time load I guess we'd spawn a probe entity, send it to the desired location, and then remove it after a moment's delay. Not too bad.

PostPosted: Fri Feb 22, 2013 15:16
by Nore
What you should do is:
- Declare a new invisible entity with force_load= true
- Create the entity at that location
- Wait 2 seconds (the server must update active blocks)
- Do your modifications
- Remove the entity

It has not been merged yet, but I wish it will be later (after all, it is my pull request).

PostPosted: Fri Feb 22, 2013 15:56
by Sokomine
That sounds good and would be very helpful! Hope it gets merged.