From: Perttu Ahola Date: Sun, 26 Dec 2010 11:51:56 +0000 (+0200) Subject: working good X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=c32da52104cc6bbe8ed0bf1ba1a7874f015cb738;p=zefram%2Fminetest%2Fminetest_engine.git working good --- diff --git a/src/heightmap.cpp b/src/heightmap.cpp index 5acb8916..6e785fcc 100644 --- a/src/heightmap.cpp +++ b/src/heightmap.cpp @@ -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) diff --git a/src/main.cpp b/src/main.cpp index 2f22caeb..bd0ebd8c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -820,7 +820,7 @@ public: s32 Rand(s32 min, s32 max) { - return (rand()%(max-min+1))+min; + return (myrand()%(max-min+1))+min; } private: bool keydown[KEY_KEY_CODES_COUNT]; @@ -830,124 +830,6 @@ private: 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="< 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 = " - <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="< #include #include +#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<