]> git.lizzy.rs Git - dragonfireclient.git/blobdiff - src/utility.cpp
Use the logger; also, default to not showing much crap in console. Use --info-on...
[dragonfireclient.git] / src / utility.cpp
index 7a43f53d22878bf406a822b9545c743b2ca9fc23..6ce67cb3fa2a1c903e415dead99c6896975e8f5e 100644 (file)
@@ -25,6 +25,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "gettime.h"
 #include "sha1.h"
 #include "base64.h"
+#include "log.h"
 
 TimeTaker::TimeTaker(const char *name, u32 *result)
 {
@@ -47,7 +48,7 @@ u32 TimeTaker::stop(bool quiet)
                else
                {
                        if(quiet == false)
-                               std::cout<<m_name<<" took "<<dtime<<"ms"<<std::endl;
+                               infostream<<m_name<<" took "<<dtime<<"ms"<<std::endl;
                }
                m_running = false;
                return dtime;
@@ -156,6 +157,21 @@ void mysrand(unsigned seed)
    next = seed;
 }
 
+int myrand_range(int min, int max)
+{
+       if(max-min > MYRAND_MAX)
+       {
+               errorstream<<"WARNING: myrand_range: max-min > MYRAND_MAX"<<std::endl;
+               assert(0);
+       }
+       if(min > max)
+       {
+               assert(0);
+               return max;
+       }
+       return (myrand()%(max-min+1))+min;
+}
+
 #ifndef SERVER
 // Sets the color of all vertices in the mesh
 void setMeshVerticesColor(scene::IMesh* mesh, video::SColor& color)