working good

master
Perttu Ahola 2010-12-26 13:51:56 +02:00
parent 4ba5cd580d
commit c32da52104
8 changed files with 65 additions and 221 deletions

View File

@ -143,7 +143,7 @@ void FixedHeightmap::makeDiamond(
f32 n = avgDiagNeighbours(center, a/2); f32 n = avgDiagNeighbours(center, a/2);
// Add (-1.0...1.0) * randmax // Add (-1.0...1.0) * randmax
n += ((float)rand() / (float)(RAND_MAX/2) - 1.0)*randmax; n += ((float)myrand() / (float)(MYRAND_MAX/2) - 1.0)*randmax;
bool worked = setGroundHeightParent(center, n); bool worked = setGroundHeightParent(center, n);
if(a >= 2 && worked) if(a >= 2 && worked)
@ -176,7 +176,7 @@ void FixedHeightmap::makeSquare(
f32 n = avgNeighbours(center, a/2); f32 n = avgNeighbours(center, a/2);
// Add (-1.0...1.0) * randmax // Add (-1.0...1.0) * randmax
n += ((float)rand() / (float)(RAND_MAX/2) - 1.0)*randmax; n += ((float)myrand() / (float)(MYRAND_MAX/2) - 1.0)*randmax;
bool worked = setGroundHeightParent(center, n); bool worked = setGroundHeightParent(center, n);
if(a >= 4 && worked) if(a >= 4 && worked)

View File

@ -820,7 +820,7 @@ public:
s32 Rand(s32 min, s32 max) s32 Rand(s32 min, s32 max)
{ {
return (rand()%(max-min+1))+min; return (myrand()%(max-min+1))+min;
} }
private: private:
bool keydown[KEY_KEY_CODES_COUNT]; bool keydown[KEY_KEY_CODES_COUNT];
@ -830,124 +830,6 @@ private:
bool rightclicked; bool rightclicked;
}; };
#if 0
void updateViewingRange(f32 frametime, Client *client)
{
// Range_all messes up frametime_avg
if(draw_control.range_all == true)
return;
float wanted_fps = g_settings.getFloat("wanted_fps");
// Initialize to the target value
static float frametime_avg = 1.0/wanted_fps;
//frametime_avg = frametime_avg * 0.9 + frametime * 0.1;
//frametime_avg = frametime_avg * 0.7 + frametime * 0.3;
//frametime_avg = frametime_avg * 0.5 + frametime * 0.5;
//frametime_avg = frametime_avg * 0.0 + frametime * 1.0;
frametime_avg = frametime_avg * 0.7 + frametime * 0.3;
static f32 counter = 0;
if(counter > 0){
counter -= frametime;
return;
}
//counter = 1.0; //seconds
counter = 0.5; //seconds
//counter += 0.1; //seconds
//counter = 0.3; //seconds
//float freetime_ratio = 0.2;
//float freetime_ratio = 0.4;
float freetime_ratio = FREETIME_RATIO;
float frametime_wanted = (1.0/(wanted_fps/(1.0-freetime_ratio)));
//float fraction = sqrt(frametime_avg / frametime_wanted);
//float fraction = pow(frametime_avg / frametime_wanted, 1./3);
float fraction_unbiased = frametime_avg / frametime_wanted;
float fraction = pow(fraction_unbiased, 20./(float)draw_control.wanted_range);
/*float fraction = 1.0;
// If frametime is too high
if(fraction_unbiased > 1.0)
fraction = pow(fraction_unbiased, 1./2);
// If frametime is too low
else
fraction = pow(fraction_unbiased, 1./5);*/
/*float fraction = sqrt(frametime_avg / frametime_wanted) / 2.0
+ frametime_avg / frametime_wanted / 2.0;*/
//float fraction = frametime_avg / frametime_wanted;
static bool fraction_is_good = false;
//float fraction_good_threshold = 0.1;
//float fraction_bad_threshold = 0.25;
/*float fraction_good_threshold = 0.075;
float fraction_bad_threshold = 0.125;*/
// If frametime is too low
/*if(fraction < 1.0)
{
fraction_good_threshold = pow(fraction_good_threshold, 4);
fraction_bad_threshold = pow(fraction_bad_threshold, 4);
}*/
float fraction_good_threshold = 0.23;
float fraction_bad_threshold = 0.33;
float fraction_limit;
// Use high limit if fraction is good AND the fraction would
// lower the range. We want to keep the range fairly high.
if(fraction_is_good && fraction > 1.0)
fraction_limit = fraction_bad_threshold;
else
fraction_limit = fraction_good_threshold;
//if(fabs(fraction - 1.0) < fraction_limit)
if(fabs(fraction_unbiased - 1.0) < fraction_limit)
{
fraction_is_good = true;
return;
}
else
{
fraction_is_good = false;
}
//dstream<<"frametime_avg="<<frametime_avg<<std::endl;
//dstream<<"frametime_wanted="<<frametime_wanted<<std::endl;
/*dstream<<"fetching="<<client->isFetchingBlocks()
<<" faction = "<<fraction<<std::endl;*/
JMutexAutoLock lock(g_range_mutex);
s16 viewing_range_nodes_min = g_settings.getS16("viewing_range_nodes_min");
s16 viewing_range_nodes_max = g_settings.getS16("viewing_range_nodes_max");
s16 n = (float)draw_control.wanted_range / fraction;
if(n < viewing_range_nodes_min)
n = viewing_range_nodes_min;
if(n > viewing_range_nodes_max)
n = viewing_range_nodes_max;
bool can_change = true;
if(client->isFetchingBlocks() == true && n > draw_control.wanted_range)
can_change = false;
if(can_change)
draw_control.wanted_range = n;
/*dstream<<"draw_control.wanted_range = "
<<draw_control.wanted_range<<std::endl;*/
}
#endif
void updateViewingRange(f32 frametime_in, Client *client) void updateViewingRange(f32 frametime_in, Client *client)
{ {
if(draw_control.range_all == true) if(draw_control.range_all == true)
@ -967,15 +849,15 @@ void updateViewingRange(f32 frametime_in, Client *client)
//counter = 0.1; //counter = 0.1;
counter = 0.2; counter = 0.2;
dstream<<__FUNCTION_NAME /*dstream<<__FUNCTION_NAME
<<": Collected "<<added_frames<<" frames, total of " <<": Collected "<<added_frames<<" frames, total of "
<<added_frametime<<"s."<<std::endl; <<added_frametime<<"s."<<std::endl;*/
dstream<<"draw_control.blocks_drawn=" /*dstream<<"draw_control.blocks_drawn="
<<draw_control.blocks_drawn <<draw_control.blocks_drawn
<<", draw_control.blocks_would_have_drawn=" <<", draw_control.blocks_would_have_drawn="
<<draw_control.blocks_would_have_drawn <<draw_control.blocks_would_have_drawn
<<std::endl; <<std::endl;*/
float range_min = g_settings.getS16("viewing_range_nodes_min"); float range_min = g_settings.getS16("viewing_range_nodes_min");
float range_max = g_settings.getS16("viewing_range_nodes_max"); float range_max = g_settings.getS16("viewing_range_nodes_max");
@ -1001,12 +883,12 @@ void updateViewingRange(f32 frametime_in, Client *client)
float wanted_frametime = 1.0 / wanted_fps; float wanted_frametime = 1.0 / wanted_fps;
f32 wanted_frametime_change = wanted_frametime - frametime; f32 wanted_frametime_change = wanted_frametime - frametime;
dstream<<"wanted_frametime_change="<<wanted_frametime_change<<std::endl; //dstream<<"wanted_frametime_change="<<wanted_frametime_change<<std::endl;
// If needed frametime change is very small, just return // If needed frametime change is very small, just return
if(fabs(wanted_frametime_change) < wanted_frametime*0.2) if(fabs(wanted_frametime_change) < wanted_frametime*0.2)
{ {
dstream<<"ignoring small wanted_frametime_change"<<std::endl; //dstream<<"ignoring small wanted_frametime_change"<<std::endl;
return; return;
} }
@ -1038,11 +920,11 @@ void updateViewingRange(f32 frametime_in, Client *client)
if(time_per_range < min_time_per_range) if(time_per_range < min_time_per_range)
{ {
time_per_range = min_time_per_range; time_per_range = min_time_per_range;
dstream<<"time_per_range="<<time_per_range<<" (min)"<<std::endl; //dstream<<"time_per_range="<<time_per_range<<" (min)"<<std::endl;
} }
else else
{ {
dstream<<"time_per_range="<<time_per_range<<std::endl; //dstream<<"time_per_range="<<time_per_range<<std::endl;
} }
f32 wanted_range_change = wanted_frametime_change / time_per_range; f32 wanted_range_change = wanted_frametime_change / time_per_range;
@ -1050,28 +932,28 @@ void updateViewingRange(f32 frametime_in, Client *client)
//wanted_range_change *= 0.9; //wanted_range_change *= 0.9;
//wanted_range_change *= 0.75; //wanted_range_change *= 0.75;
wanted_range_change *= 0.5; wanted_range_change *= 0.5;
dstream<<"wanted_range_change="<<wanted_range_change<<std::endl; //dstream<<"wanted_range_change="<<wanted_range_change<<std::endl;
// If needed range change is very small, just return // If needed range change is very small, just return
if(fabs(wanted_range_change) < 0.001) if(fabs(wanted_range_change) < 0.001)
{ {
dstream<<"ignoring small wanted_range_change"<<std::endl; //dstream<<"ignoring small wanted_range_change"<<std::endl;
return; return;
} }
new_range += wanted_range_change; new_range += wanted_range_change;
dstream<<"new_range="<<new_range/*<<std::endl*/; //dstream<<"new_range="<<new_range/*<<std::endl*/;
float new_range_unclamped = new_range; //float new_range_unclamped = new_range;
if(new_range < range_min) if(new_range < range_min)
new_range = range_min; new_range = range_min;
if(new_range > range_max) if(new_range > range_max)
new_range = range_max; new_range = range_max;
if(new_range != new_range_unclamped) /*if(new_range != new_range_unclamped)
dstream<<", clamped to "<<new_range<<std::endl; dstream<<", clamped to "<<new_range<<std::endl;
else else
dstream<<std::endl; dstream<<std::endl;*/
draw_control.wanted_range = new_range; draw_control.wanted_range = new_range;

View File

@ -26,45 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "voxel.h" #include "voxel.h"
#include "porting.h" #include "porting.h"
#if 0
MapBlockPointerCache::MapBlockPointerCache(Map *map)
{
m_map = map;
m_map->m_blockcachelock.cacheCreated();
m_from_cache_count = 0;
m_from_map_count = 0;
}
MapBlockPointerCache::~MapBlockPointerCache()
{
m_map->m_blockcachelock.cacheRemoved();
/*dstream<<"MapBlockPointerCache:"
<<" from_cache_count="<<m_from_cache_count
<<" from_map_count="<<m_from_map_count
<<std::endl;*/
}
MapBlock * MapBlockPointerCache::getBlockNoCreate(v3s16 p)
{
core::map<v3s16, MapBlock*>::Node *n = NULL;
n = m_blocks.find(p);
if(n != NULL)
{
m_from_cache_count++;
return n->getValue();
}
m_from_map_count++;
// Throws InvalidPositionException if not found
MapBlock *b = m_map->getBlockNoCreate(p);
m_blocks[p] = b;
return b;
}
#endif
/* /*
Map Map
*/ */
@ -1573,12 +1534,12 @@ MapSector * ServerMap::emergeSector(v2s16 p2d)
tree_max = a / (t/0.03); tree_max = a / (t/0.03);
else else
tree_max = a; tree_max = a;
u32 count = (rand()%(tree_max+1)); u32 count = (myrand()%(tree_max+1));
//u32 count = tree_max; //u32 count = tree_max;
for(u32 i=0; i<count; i++) for(u32 i=0; i<count; i++)
{ {
s16 x = (rand()%(MAP_BLOCKSIZE-2))+1; s16 x = (myrand()%(MAP_BLOCKSIZE-2))+1;
s16 z = (rand()%(MAP_BLOCKSIZE-2))+1; s16 z = (myrand()%(MAP_BLOCKSIZE-2))+1;
s16 y = sector->getGroundHeight(v2s16(x,z))+1; s16 y = sector->getGroundHeight(v2s16(x,z))+1;
if(y < WATER_LEVEL) if(y < WATER_LEVEL)
continue; continue;
@ -1597,11 +1558,11 @@ MapSector * ServerMap::emergeSector(v2s16 p2d)
bush_max = (pitness*a*4); bush_max = (pitness*a*4);
if(bush_max > a) if(bush_max > a)
bush_max = a; bush_max = a;
u32 count = (rand()%(bush_max+1)); u32 count = (myrand()%(bush_max+1));
for(u32 i=0; i<count; i++) for(u32 i=0; i<count; i++)
{ {
s16 x = rand()%(MAP_BLOCKSIZE-0)+0; s16 x = myrand()%(MAP_BLOCKSIZE-0)+0;
s16 z = rand()%(MAP_BLOCKSIZE-0)+0; s16 z = myrand()%(MAP_BLOCKSIZE-0)+0;
s16 y = sector->getGroundHeight(v2s16(x,z))+1; s16 y = sector->getGroundHeight(v2s16(x,z))+1;
if(y < WATER_LEVEL) if(y < WATER_LEVEL)
continue; continue;
@ -1614,11 +1575,11 @@ MapSector * ServerMap::emergeSector(v2s16 p2d)
*/ */
if(m_params.ravines_amount != 0) if(m_params.ravines_amount != 0)
{ {
if(rand()%(s32)(20.0 / m_params.ravines_amount) == 0) if(myrand()%(s32)(20.0 / m_params.ravines_amount) == 0)
{ {
s16 s = 6; s16 s = 6;
s16 x = rand()%(MAP_BLOCKSIZE-s*2-1)+s; s16 x = myrand()%(MAP_BLOCKSIZE-s*2-1)+s;
s16 z = rand()%(MAP_BLOCKSIZE-s*2-1)+s; s16 z = myrand()%(MAP_BLOCKSIZE-s*2-1)+s;
/*s16 x = 8; /*s16 x = 8;
s16 z = 8;*/ s16 z = 8;*/
s16 y = sector->getGroundHeight(v2s16(x,z))+1; s16 y = sector->getGroundHeight(v2s16(x,z))+1;
@ -1737,11 +1698,11 @@ MapBlock * ServerMap::emergeBlock(
const s32 ued_max = 5; const s32 ued_max = 5;
const s32 ued_min = 3; const s32 ued_min = 3;
bool underground_emptiness[ued_max*ued_max*ued_max]; bool underground_emptiness[ued_max*ued_max*ued_max];
s32 ued = (rand()%(ued_max-ued_min+1))+1; s32 ued = (myrand()%(ued_max-ued_min+1))+1;
//s32 ued = ued_max; //s32 ued = ued_max;
for(s32 i=0; i<ued*ued*ued; i++) for(s32 i=0; i<ued*ued*ued; i++)
{ {
underground_emptiness[i] = ((rand() % 5) == 0); underground_emptiness[i] = ((myrand() % 5) == 0);
} }
/* /*
@ -1830,9 +1791,9 @@ MapBlock * ServerMap::emergeBlock(
*/ */
v3f orp( v3f orp(
(float)(rand()%ued)+0.5, (float)(myrand()%ued)+0.5,
(float)(rand()%ued)+0.5, (float)(myrand()%ued)+0.5,
(float)(rand()%ued)+0.5 (float)(myrand()%ued)+0.5
); );
// Check z- // Check z-
@ -1911,13 +1872,13 @@ continue_generating:
for(u16 i=0; i<3; i++) for(u16 i=0; i<3; i++)
{ {
v3f rp( v3f rp(
(float)(rand()%ued)+0.5, (float)(myrand()%ued)+0.5,
(float)(rand()%ued)+0.5, (float)(myrand()%ued)+0.5,
(float)(rand()%ued)+0.5 (float)(myrand()%ued)+0.5
); );
s16 min_d = 0; s16 min_d = 0;
s16 max_d = 4; s16 max_d = 4;
s16 rs = (rand()%(max_d-min_d+1))+min_d; s16 rs = (myrand()%(max_d-min_d+1))+min_d;
v3f vec = rp - orp; v3f vec = rp - orp;
@ -2098,12 +2059,12 @@ continue_generating:
*/ */
for(s16 i=0; i<underground_level*1; i++) for(s16 i=0; i<underground_level*1; i++)
{ {
if(rand()%2 == 0) if(myrand()%2 == 0)
{ {
v3s16 cp( v3s16 cp(
(rand()%(MAP_BLOCKSIZE-2))+1, (myrand()%(MAP_BLOCKSIZE-2))+1,
(rand()%(MAP_BLOCKSIZE-2))+1, (myrand()%(MAP_BLOCKSIZE-2))+1,
(rand()%(MAP_BLOCKSIZE-2))+1 (myrand()%(MAP_BLOCKSIZE-2))+1
); );
MapNode n; MapNode n;
@ -2111,14 +2072,14 @@ continue_generating:
//if(is_ground_content(block->getNode(cp).d)) //if(is_ground_content(block->getNode(cp).d))
if(block->getNode(cp).d == CONTENT_STONE) if(block->getNode(cp).d == CONTENT_STONE)
if(rand()%8 == 0) if(myrand()%8 == 0)
block->setNode(cp, n); block->setNode(cp, n);
for(u16 i=0; i<26; i++) for(u16 i=0; i<26; i++)
{ {
//if(is_ground_content(block->getNode(cp+g_26dirs[i]).d)) //if(is_ground_content(block->getNode(cp+g_26dirs[i]).d))
if(block->getNode(cp+g_26dirs[i]).d == CONTENT_STONE) if(block->getNode(cp+g_26dirs[i]).d == CONTENT_STONE)
if(rand()%8 == 0) if(myrand()%8 == 0)
block->setNode(cp+g_26dirs[i], n); block->setNode(cp+g_26dirs[i], n);
} }
} }
@ -2131,16 +2092,16 @@ continue_generating:
u16 coal_rareness = 60 / coal_amount; u16 coal_rareness = 60 / coal_amount;
if(coal_rareness == 0) if(coal_rareness == 0)
coal_rareness = 1; coal_rareness = 1;
if(rand()%coal_rareness == 0) if(myrand()%coal_rareness == 0)
{ {
u16 a = rand() % 16; u16 a = myrand() % 16;
u16 amount = coal_amount * a*a*a / 1000; u16 amount = coal_amount * a*a*a / 1000;
for(s16 i=0; i<amount; i++) for(s16 i=0; i<amount; i++)
{ {
v3s16 cp( v3s16 cp(
(rand()%(MAP_BLOCKSIZE-2))+1, (myrand()%(MAP_BLOCKSIZE-2))+1,
(rand()%(MAP_BLOCKSIZE-2))+1, (myrand()%(MAP_BLOCKSIZE-2))+1,
(rand()%(MAP_BLOCKSIZE-2))+1 (myrand()%(MAP_BLOCKSIZE-2))+1
); );
MapNode n; MapNode n;
@ -2150,14 +2111,14 @@ continue_generating:
//if(is_ground_content(block->getNode(cp).d)) //if(is_ground_content(block->getNode(cp).d))
if(block->getNode(cp).d == CONTENT_STONE) if(block->getNode(cp).d == CONTENT_STONE)
if(rand()%8 == 0) if(myrand()%8 == 0)
block->setNode(cp, n); block->setNode(cp, n);
for(u16 i=0; i<26; i++) for(u16 i=0; i<26; i++)
{ {
//if(is_ground_content(block->getNode(cp+g_26dirs[i]).d)) //if(is_ground_content(block->getNode(cp+g_26dirs[i]).d))
if(block->getNode(cp+g_26dirs[i]).d == CONTENT_STONE) if(block->getNode(cp+g_26dirs[i]).d == CONTENT_STONE)
if(rand()%8 == 0) if(myrand()%8 == 0)
block->setNode(cp+g_26dirs[i], n); block->setNode(cp+g_26dirs[i], n);
} }
} }
@ -2172,9 +2133,9 @@ continue_generating:
//for(u16 i=0; i<2; i++) //for(u16 i=0; i<2; i++)
{ {
v3s16 cp( v3s16 cp(
(rand()%(MAP_BLOCKSIZE-2))+1, (myrand()%(MAP_BLOCKSIZE-2))+1,
(rand()%(MAP_BLOCKSIZE-2))+1, (myrand()%(MAP_BLOCKSIZE-2))+1,
(rand()%(MAP_BLOCKSIZE-2))+1 (myrand()%(MAP_BLOCKSIZE-2))+1
); );
// Check that the place is empty // Check that the place is empty
@ -2295,18 +2256,18 @@ continue_generating:
n.d = CONTENT_STONE; n.d = CONTENT_STONE;
MapNode n2; MapNode n2;
n2.d = CONTENT_AIR; n2.d = CONTENT_AIR;
s16 depth = maxdepth + (rand()%10); s16 depth = maxdepth + (myrand()%10);
s16 z = 0; s16 z = 0;
s16 minz = -6 - (-2); s16 minz = -6 - (-2);
s16 maxz = 6 -1; s16 maxz = 6 -1;
for(s16 x=-6; x<=6; x++) for(s16 x=-6; x<=6; x++)
{ {
z += -1 + (rand()%3); z += -1 + (myrand()%3);
if(z < minz) if(z < minz)
z = minz; z = minz;
if(z > maxz) if(z > maxz)
z = maxz; z = maxz;
for(s16 y=depth+(rand()%2); y<=6; y++) for(s16 y=depth+(myrand()%2); y<=6; y++)
{ {
/*std::cout<<"("<<p2.X<<","<<p2.Y<<","<<p2.Z<<")" /*std::cout<<"("<<p2.X<<","<<p2.Y<<","<<p2.Z<<")"
<<std::endl;*/ <<std::endl;*/

View File

@ -1021,11 +1021,11 @@ void MapBlock::stepObjects(float dtime, bool server, u32 daynight_ratio)
m_spawn_timer -= dtime; m_spawn_timer -= dtime;
if(m_spawn_timer <= 0.0) if(m_spawn_timer <= 0.0)
{ {
m_spawn_timer += rand() % 300; m_spawn_timer += myrand() % 300;
v2s16 p2d( v2s16 p2d(
(rand()%(MAP_BLOCKSIZE-1))+0, (myrand()%(MAP_BLOCKSIZE-1))+0,
(rand()%(MAP_BLOCKSIZE-1))+0 (myrand()%(MAP_BLOCKSIZE-1))+0
); );
s16 y = getGroundLevel(p2d); s16 y = getGroundLevel(p2d);

View File

@ -630,8 +630,8 @@ public:
m_counter2 -= dtime; m_counter2 -= dtime;
if(m_counter2 < 0.0) if(m_counter2 < 0.0)
{ {
m_counter2 += (float)(rand()%100)/100*3.0; m_counter2 += (float)(myrand()%100)/100*3.0;
m_yaw += ((float)(rand()%200)-100)/100*180; m_yaw += ((float)(myrand()%200)-100)/100*180;
m_yaw = wrapDegrees(m_yaw); m_yaw = wrapDegrees(m_yaw);
} }
} }

View File

@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include <iostream> #include <iostream>
#include <stdlib.h> #include <stdlib.h>
#include <errno.h> #include <errno.h>
#include "utility.h"
// Debug printing options // Debug printing options
#define DP 0 #define DP 0
@ -194,8 +195,8 @@ void UDPSocket::Send(const Address & destination, const void * data, int size)
{ {
bool dumping_packet = false; bool dumping_packet = false;
if(INTERNET_SIMULATOR) if(INTERNET_SIMULATOR)
dumping_packet = (rand()%10==0); //easy dumping_packet = (myrand()%10==0); //easy
//dumping_packet = (rand()%4==0); // hard //dumping_packet = (myrand()%4==0); // hard
if(DP){ if(DP){
/*dstream<<DPS<<"UDPSocket("<<(int)m_handle /*dstream<<DPS<<"UDPSocket("<<(int)m_handle

View File

@ -723,9 +723,9 @@ struct TestHeightmap
void Random() void Random()
{ {
dstream<<"Running random code (get a human to check this)"<<std::endl; dstream<<"Running random code (get a human to check this)"<<std::endl;
dstream<<"rand() values: "; dstream<<"myrand() values: ";
for(u16 i=0; i<5; i++) for(u16 i=0; i<5; i++)
dstream<<(u16)rand()<<" "; dstream<<(u16)myrand()<<" ";
dstream<<std::endl; dstream<<std::endl;
const s16 BS1 = 8; const s16 BS1 = 8;

View File

@ -893,7 +893,7 @@ void VoxelManipulator::flowWater(
*/ */
s32 k = 0; s32 k = 0;
if(active_nodes.size() != 0) if(active_nodes.size() != 0)
k = (s32)rand() % (s32)active_nodes.size(); k = (s32)myrand() % (s32)active_nodes.size();
// Flow water to active nodes // Flow water to active nodes
for(;;) for(;;)