working good
authorPerttu Ahola <celeron55@gmail.com>
Sun, 26 Dec 2010 11:51:56 +0000 (13:51 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Sun, 26 Dec 2010 11:51:56 +0000 (13:51 +0200)
src/heightmap.cpp
src/main.cpp
src/map.cpp
src/mapblock.cpp
src/mapblockobject.h
src/socket.cpp
src/test.cpp
src/voxel.cpp

index 5acb8916b0ce64fc776a123db42397ec7d601ec6..6e785fcc5868e42a4ce028b2faf12c1b0d01aa7f 100644 (file)
@@ -143,7 +143,7 @@ void FixedHeightmap::makeDiamond(
 
        f32 n = avgDiagNeighbours(center, a/2);
        // 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);
        
        if(a >= 2 && worked)
@@ -176,7 +176,7 @@ void FixedHeightmap::makeSquare(
 
        f32 n = avgNeighbours(center, a/2);
        // 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);
        
        if(a >= 4 && worked)
index 2f22caeb011b499cc5fe076eba5d6048cd426154..bd0ebd8cae79f0e78a16423483e6fd12e466d75c 100644 (file)
@@ -820,7 +820,7 @@ public:
 \r
        s32 Rand(s32 min, s32 max)\r
        {\r
-               return (rand()%(max-min+1))+min;\r
+               return (myrand()%(max-min+1))+min;\r
        }\r
 private:\r
        bool keydown[KEY_KEY_CODES_COUNT];\r
@@ -830,124 +830,6 @@ private:
        bool rightclicked;\r
 };\r
 \r
-#if 0\r
-void updateViewingRange(f32 frametime, Client *client)\r
-{\r
-       // Range_all messes up frametime_avg\r
-       if(draw_control.range_all == true)\r
-               return;\r
-\r
-       float wanted_fps = g_settings.getFloat("wanted_fps");\r
-       \r
-       // Initialize to the target value\r
-       static float frametime_avg = 1.0/wanted_fps;\r
-       //frametime_avg = frametime_avg * 0.9 + frametime * 0.1;\r
-       //frametime_avg = frametime_avg * 0.7 + frametime * 0.3;\r
-       //frametime_avg = frametime_avg * 0.5 + frametime * 0.5;\r
-       //frametime_avg = frametime_avg * 0.0 + frametime * 1.0;\r
-       frametime_avg = frametime_avg * 0.7 + frametime * 0.3;\r
-\r
-       static f32 counter = 0;\r
-       if(counter > 0){\r
-               counter -= frametime;\r
-               return;\r
-       }\r
-       //counter = 1.0; //seconds\r
-       counter = 0.5; //seconds\r
-       //counter += 0.1; //seconds\r
-       //counter = 0.3; //seconds\r
-\r
-       //float freetime_ratio = 0.2;\r
-       //float freetime_ratio = 0.4;\r
-       float freetime_ratio = FREETIME_RATIO;\r
-\r
-       float frametime_wanted = (1.0/(wanted_fps/(1.0-freetime_ratio)));\r
-\r
-       //float fraction = sqrt(frametime_avg / frametime_wanted);\r
-       //float fraction = pow(frametime_avg / frametime_wanted, 1./3);\r
-\r
-       float fraction_unbiased = frametime_avg / frametime_wanted;\r
-\r
-       float fraction = pow(fraction_unbiased, 20./(float)draw_control.wanted_range);\r
-       \r
-       /*float fraction = 1.0;\r
-       // If frametime is too high\r
-       if(fraction_unbiased > 1.0)\r
-               fraction = pow(fraction_unbiased, 1./2);\r
-       // If frametime is too low\r
-       else\r
-               fraction = pow(fraction_unbiased, 1./5);*/\r
-\r
-       /*float fraction = sqrt(frametime_avg / frametime_wanted) / 2.0\r
-                       + frametime_avg / frametime_wanted / 2.0;*/\r
-       \r
-       //float fraction = frametime_avg / frametime_wanted;\r
-\r
-       static bool fraction_is_good = false;\r
-       \r
-       //float fraction_good_threshold = 0.1;\r
-       //float fraction_bad_threshold = 0.25;\r
-\r
-       /*float fraction_good_threshold = 0.075;\r
-       float fraction_bad_threshold = 0.125;*/\r
-       // If frametime is too low\r
-       /*if(fraction < 1.0)\r
-       {\r
-               fraction_good_threshold = pow(fraction_good_threshold, 4);\r
-               fraction_bad_threshold = pow(fraction_bad_threshold, 4);\r
-       }*/\r
-\r
-       float fraction_good_threshold = 0.23;\r
-       float fraction_bad_threshold = 0.33;\r
-       \r
-       float fraction_limit;\r
-       // Use high limit if fraction is good AND the fraction would\r
-       // lower the range. We want to keep the range fairly high.\r
-       if(fraction_is_good && fraction > 1.0)\r
-               fraction_limit = fraction_bad_threshold;\r
-       else\r
-               fraction_limit = fraction_good_threshold;\r
-\r
-       //if(fabs(fraction - 1.0) < fraction_limit)\r
-       if(fabs(fraction_unbiased - 1.0) < fraction_limit)\r
-       {\r
-               fraction_is_good = true;\r
-               return;\r
-       }\r
-       else\r
-       {\r
-               fraction_is_good = false;\r
-       }\r
-\r
-       //dstream<<"frametime_avg="<<frametime_avg<<std::endl;\r
-       //dstream<<"frametime_wanted="<<frametime_wanted<<std::endl;\r
-       /*dstream<<"fetching="<<client->isFetchingBlocks()\r
-                       <<" faction = "<<fraction<<std::endl;*/\r
-\r
-       JMutexAutoLock lock(g_range_mutex);\r
-       \r
-       s16 viewing_range_nodes_min = g_settings.getS16("viewing_range_nodes_min");\r
-       s16 viewing_range_nodes_max = g_settings.getS16("viewing_range_nodes_max");\r
-\r
-       s16 n = (float)draw_control.wanted_range / fraction;\r
-       if(n < viewing_range_nodes_min)\r
-               n = viewing_range_nodes_min;\r
-       if(n > viewing_range_nodes_max)\r
-               n = viewing_range_nodes_max;\r
-\r
-       bool can_change = true;\r
-\r
-       if(client->isFetchingBlocks() == true && n > draw_control.wanted_range)\r
-               can_change = false;\r
-       \r
-       if(can_change)\r
-               draw_control.wanted_range = n;\r
-\r
-       /*dstream<<"draw_control.wanted_range = "\r
-                       <<draw_control.wanted_range<<std::endl;*/\r
-}\r
-#endif\r
-\r
 void updateViewingRange(f32 frametime_in, Client *client)\r
 {\r
        if(draw_control.range_all == true)\r
@@ -967,15 +849,15 @@ void updateViewingRange(f32 frametime_in, Client *client)
        //counter = 0.1;\r
        counter = 0.2;\r
 \r
-       dstream<<__FUNCTION_NAME\r
+       /*dstream<<__FUNCTION_NAME\r
                        <<": Collected "<<added_frames<<" frames, total of "\r
-                       <<added_frametime<<"s."<<std::endl;\r
+                       <<added_frametime<<"s."<<std::endl;*/\r
        \r
-       dstream<<"draw_control.blocks_drawn="\r
+       /*dstream<<"draw_control.blocks_drawn="\r
                        <<draw_control.blocks_drawn\r
                        <<", draw_control.blocks_would_have_drawn="\r
                        <<draw_control.blocks_would_have_drawn\r
-                       <<std::endl;\r
+                       <<std::endl;*/\r
        \r
        float range_min = g_settings.getS16("viewing_range_nodes_min");\r
        float range_max = g_settings.getS16("viewing_range_nodes_max");\r
@@ -1001,12 +883,12 @@ void updateViewingRange(f32 frametime_in, Client *client)
        float wanted_frametime = 1.0 / wanted_fps;\r
        \r
        f32 wanted_frametime_change = wanted_frametime - frametime;\r
-       dstream<<"wanted_frametime_change="<<wanted_frametime_change<<std::endl;\r
+       //dstream<<"wanted_frametime_change="<<wanted_frametime_change<<std::endl;\r
        \r
        // If needed frametime change is very small, just return\r
        if(fabs(wanted_frametime_change) < wanted_frametime*0.2)\r
        {\r
-               dstream<<"ignoring small wanted_frametime_change"<<std::endl;\r
+               //dstream<<"ignoring small wanted_frametime_change"<<std::endl;\r
                return;\r
        }\r
 \r
@@ -1038,11 +920,11 @@ void updateViewingRange(f32 frametime_in, Client *client)
        if(time_per_range < min_time_per_range)\r
        {\r
                time_per_range = min_time_per_range;\r
-               dstream<<"time_per_range="<<time_per_range<<" (min)"<<std::endl;\r
+               //dstream<<"time_per_range="<<time_per_range<<" (min)"<<std::endl;\r
        }\r
        else\r
        {\r
-               dstream<<"time_per_range="<<time_per_range<<std::endl;\r
+               //dstream<<"time_per_range="<<time_per_range<<std::endl;\r
        }\r
 \r
        f32 wanted_range_change = wanted_frametime_change / time_per_range;\r
@@ -1050,28 +932,28 @@ void updateViewingRange(f32 frametime_in, Client *client)
        //wanted_range_change *= 0.9;\r
        //wanted_range_change *= 0.75;\r
        wanted_range_change *= 0.5;\r
-       dstream<<"wanted_range_change="<<wanted_range_change<<std::endl;\r
+       //dstream<<"wanted_range_change="<<wanted_range_change<<std::endl;\r
 \r
        // If needed range change is very small, just return\r
        if(fabs(wanted_range_change) < 0.001)\r
        {\r
-               dstream<<"ignoring small wanted_range_change"<<std::endl;\r
+               //dstream<<"ignoring small wanted_range_change"<<std::endl;\r
                return;\r
        }\r
 \r
        new_range += wanted_range_change;\r
-       dstream<<"new_range="<<new_range/*<<std::endl*/;\r
+       //dstream<<"new_range="<<new_range/*<<std::endl*/;\r
        \r
-       float new_range_unclamped = new_range;\r
+       //float new_range_unclamped = new_range;\r
        if(new_range < range_min)\r
                new_range = range_min;\r
        if(new_range > range_max)\r
                new_range = range_max;\r
        \r
-       if(new_range != new_range_unclamped)\r
+       /*if(new_range != new_range_unclamped)\r
                dstream<<", clamped to "<<new_range<<std::endl;\r
        else\r
-               dstream<<std::endl;\r
+               dstream<<std::endl;*/\r
 \r
        draw_control.wanted_range = new_range;\r
 \r
index b092e1fa538780dcfc656cd2d47246a4b6f52c83..1bd4f299f05f6eb75884641e30170151a930a825 100644 (file)
@@ -26,45 +26,6 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "voxel.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
 */
@@ -1573,12 +1534,12 @@ MapSector * ServerMap::emergeSector(v2s16 p2d)
                        tree_max = a / (t/0.03);
                else
                        tree_max = a;
-               u32 count = (rand()%(tree_max+1));
+               u32 count = (myrand()%(tree_max+1));
                //u32 count = tree_max;
                for(u32 i=0; i<count; i++)
                {
-                       s16 x = (rand()%(MAP_BLOCKSIZE-2))+1;
-                       s16 z = (rand()%(MAP_BLOCKSIZE-2))+1;
+                       s16 x = (myrand()%(MAP_BLOCKSIZE-2))+1;
+                       s16 z = (myrand()%(MAP_BLOCKSIZE-2))+1;
                        s16 y = sector->getGroundHeight(v2s16(x,z))+1;
                        if(y < WATER_LEVEL)
                                continue;
@@ -1597,11 +1558,11 @@ MapSector * ServerMap::emergeSector(v2s16 p2d)
                        bush_max = (pitness*a*4);
                if(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++)
                {
-                       s16 x = rand()%(MAP_BLOCKSIZE-0)+0;
-                       s16 z = rand()%(MAP_BLOCKSIZE-0)+0;
+                       s16 x = myrand()%(MAP_BLOCKSIZE-0)+0;
+                       s16 z = myrand()%(MAP_BLOCKSIZE-0)+0;
                        s16 y = sector->getGroundHeight(v2s16(x,z))+1;
                        if(y < WATER_LEVEL)
                                continue;
@@ -1614,11 +1575,11 @@ MapSector * ServerMap::emergeSector(v2s16 p2d)
        */
        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 x = rand()%(MAP_BLOCKSIZE-s*2-1)+s;
-                       s16 z = rand()%(MAP_BLOCKSIZE-s*2-1)+s;
+                       s16 x = myrand()%(MAP_BLOCKSIZE-s*2-1)+s;
+                       s16 z = myrand()%(MAP_BLOCKSIZE-s*2-1)+s;
                        /*s16 x = 8;
                        s16 z = 8;*/
                        s16 y = sector->getGroundHeight(v2s16(x,z))+1;
@@ -1737,11 +1698,11 @@ MapBlock * ServerMap::emergeBlock(
        const s32 ued_max = 5;
        const s32 ued_min = 3;
        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;
        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(
-                       (float)(rand()%ued)+0.5,
-                       (float)(rand()%ued)+0.5,
-                       (float)(rand()%ued)+0.5
+                       (float)(myrand()%ued)+0.5,
+                       (float)(myrand()%ued)+0.5,
+                       (float)(myrand()%ued)+0.5
                );
 
                // Check z-
@@ -1911,13 +1872,13 @@ continue_generating:
                for(u16 i=0; i<3; i++)
                {
                        v3f rp(
-                               (float)(rand()%ued)+0.5,
-                               (float)(rand()%ued)+0.5,
-                               (float)(rand()%ued)+0.5
+                               (float)(myrand()%ued)+0.5,
+                               (float)(myrand()%ued)+0.5,
+                               (float)(myrand()%ued)+0.5
                        );
                        s16 min_d = 0;
                        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;
 
@@ -2098,12 +2059,12 @@ continue_generating:
                */
                for(s16 i=0; i<underground_level*1; i++)
                {
-                       if(rand()%2 == 0)
+                       if(myrand()%2 == 0)
                        {
                                v3s16 cp(
-                                       (rand()%(MAP_BLOCKSIZE-2))+1,
-                                       (rand()%(MAP_BLOCKSIZE-2))+1,
-                                       (rand()%(MAP_BLOCKSIZE-2))+1
+                                       (myrand()%(MAP_BLOCKSIZE-2))+1,
+                                       (myrand()%(MAP_BLOCKSIZE-2))+1,
+                                       (myrand()%(MAP_BLOCKSIZE-2))+1
                                );
 
                                MapNode n;
@@ -2111,14 +2072,14 @@ continue_generating:
                                
                                //if(is_ground_content(block->getNode(cp).d))
                                if(block->getNode(cp).d == CONTENT_STONE)
-                                       if(rand()%8 == 0)
+                                       if(myrand()%8 == 0)
                                                block->setNode(cp, n);
 
                                for(u16 i=0; i<26; i++)
                                {
                                        //if(is_ground_content(block->getNode(cp+g_26dirs[i]).d))
                                        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);
                                }
                        }
@@ -2131,16 +2092,16 @@ continue_generating:
                u16 coal_rareness = 60 / coal_amount;
                if(coal_rareness == 0)
                        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;
                        for(s16 i=0; i<amount; i++)
                        {
                                v3s16 cp(
-                                       (rand()%(MAP_BLOCKSIZE-2))+1,
-                                       (rand()%(MAP_BLOCKSIZE-2))+1,
-                                       (rand()%(MAP_BLOCKSIZE-2))+1
+                                       (myrand()%(MAP_BLOCKSIZE-2))+1,
+                                       (myrand()%(MAP_BLOCKSIZE-2))+1,
+                                       (myrand()%(MAP_BLOCKSIZE-2))+1
                                );
 
                                MapNode n;
@@ -2150,14 +2111,14 @@ continue_generating:
                                
                                //if(is_ground_content(block->getNode(cp).d))
                                if(block->getNode(cp).d == CONTENT_STONE)
-                                       if(rand()%8 == 0)
+                                       if(myrand()%8 == 0)
                                                block->setNode(cp, n);
 
                                for(u16 i=0; i<26; i++)
                                {
                                        //if(is_ground_content(block->getNode(cp+g_26dirs[i]).d))
                                        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);
                                }
                        }
@@ -2172,9 +2133,9 @@ continue_generating:
                //for(u16 i=0; i<2; i++)
                {
                        v3s16 cp(
-                               (rand()%(MAP_BLOCKSIZE-2))+1,
-                               (rand()%(MAP_BLOCKSIZE-2))+1,
-                               (rand()%(MAP_BLOCKSIZE-2))+1
+                               (myrand()%(MAP_BLOCKSIZE-2))+1,
+                               (myrand()%(MAP_BLOCKSIZE-2))+1,
+                               (myrand()%(MAP_BLOCKSIZE-2))+1
                        );
 
                        // Check that the place is empty
@@ -2295,18 +2256,18 @@ continue_generating:
                                n.d = CONTENT_STONE;
                                MapNode n2;
                                n2.d = CONTENT_AIR;
-                               s16 depth = maxdepth + (rand()%10);
+                               s16 depth = maxdepth + (myrand()%10);
                                s16 z = 0;
                                s16 minz = -6 - (-2);
                                s16 maxz = 6 -1;
                                for(s16 x=-6; x<=6; x++)
                                {
-                                       z += -1 + (rand()%3);
+                                       z += -1 + (myrand()%3);
                                        if(z < minz)
                                                z = minz;
                                        if(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::endl;*/
index 186256589fded7eaac1514379d2701b151adf5b7..60efa2fcfa1f015728fb3966d2df9d413b0d622b 100644 (file)
@@ -1021,11 +1021,11 @@ void MapBlock::stepObjects(float dtime, bool server, u32 daynight_ratio)
                m_spawn_timer -= dtime;
                if(m_spawn_timer <= 0.0)
                {
-                       m_spawn_timer += rand() % 300;
+                       m_spawn_timer += myrand() % 300;
                        
                        v2s16 p2d(
-                               (rand()%(MAP_BLOCKSIZE-1))+0,
-                               (rand()%(MAP_BLOCKSIZE-1))+0
+                               (myrand()%(MAP_BLOCKSIZE-1))+0,
+                               (myrand()%(MAP_BLOCKSIZE-1))+0
                        );
 
                        s16 y = getGroundLevel(p2d);
index 08f535514f7ca94c7fde155533d056dd7120b265..aee41f3ba1620cb7e48eb7f08015932ab8f59958 100644 (file)
@@ -630,8 +630,8 @@ public:
                        m_counter2 -= dtime;
                        if(m_counter2 < 0.0)
                        {
-                               m_counter2 += (float)(rand()%100)/100*3.0;
-                               m_yaw += ((float)(rand()%200)-100)/100*180;
+                               m_counter2 += (float)(myrand()%100)/100*3.0;
+                               m_yaw += ((float)(myrand()%200)-100)/100*180;
                                m_yaw = wrapDegrees(m_yaw);
                        }
                }
index f4b8f442943aaf78834569547ab376763a65aef0..499ee504e0d7e33c3c793577a5f040b2971a8486 100644 (file)
@@ -23,6 +23,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include <iostream>
 #include <stdlib.h>
 #include <errno.h>
+#include "utility.h"
 
 // Debug printing options
 #define DP 0
@@ -194,8 +195,8 @@ void UDPSocket::Send(const Address & destination, const void * data, int size)
 {
        bool dumping_packet = false;
        if(INTERNET_SIMULATOR)
-               dumping_packet = (rand()%10==0); //easy
-               //dumping_packet = (rand()%4==0); // hard
+               dumping_packet = (myrand()%10==0); //easy
+               //dumping_packet = (myrand()%4==0); // hard
 
        if(DP){
                /*dstream<<DPS<<"UDPSocket("<<(int)m_handle
index 142918df622edd414b42a7788cd010b32fb3af5a..38c663236a2e5267cf7d9ea94c3e68e1f9bdbc65 100644 (file)
@@ -723,9 +723,9 @@ struct TestHeightmap
        void Random()
        {
                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++)
-                       dstream<<(u16)rand()<<" ";
+                       dstream<<(u16)myrand()<<" ";
                dstream<<std::endl;
 
                const s16 BS1 = 8;
index 55cd73893c3a6cae96f2ab27bf8785902dd3ed1b..2fd4e7b457ab4bef1f0b64f8cfd38e4ef48dba3f 100644 (file)
@@ -893,7 +893,7 @@ void VoxelManipulator::flowWater(
        */
        s32 k = 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
        for(;;)