summaryrefslogtreecommitdiffstats
path: root/source/cMonster.cpp
diff options
context:
space:
mode:
authormtilden@gmail.com <mtilden@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-26 10:09:47 +0100
committermtilden@gmail.com <mtilden@gmail.com@0a769ca7-a7f5-676a-18bf-c427514a06d6>2011-12-26 10:09:47 +0100
commitc7fa610be3b6e072d3da4611f6de72390ebbf446 (patch)
treeeaa1e1d08d9136c78228ec067f4d41b1d33ef320 /source/cMonster.cpp
parent - Added timer to cPlayer PlayerListItem because sending the packets like minecraft does (every tick per player) is 20 pps per client to each client and was causing Kicks for having too high of a packet queue (diff)
downloadcuberite-c7fa610be3b6e072d3da4611f6de72390ebbf446.tar
cuberite-c7fa610be3b6e072d3da4611f6de72390ebbf446.tar.gz
cuberite-c7fa610be3b6e072d3da4611f6de72390ebbf446.tar.bz2
cuberite-c7fa610be3b6e072d3da4611f6de72390ebbf446.tar.lz
cuberite-c7fa610be3b6e072d3da4611f6de72390ebbf446.tar.xz
cuberite-c7fa610be3b6e072d3da4611f6de72390ebbf446.tar.zst
cuberite-c7fa610be3b6e072d3da4611f6de72390ebbf446.zip
Diffstat (limited to '')
-rw-r--r--source/cMonster.cpp14
1 files changed, 9 insertions, 5 deletions
diff --git a/source/cMonster.cpp b/source/cMonster.cpp
index 18afcf8b0..217cd5367 100644
--- a/source/cMonster.cpp
+++ b/source/cMonster.cpp
@@ -11,6 +11,7 @@
#include "cPickup.h"
#include "cItem.h"
#include "cMonsterConfig.h"
+#include "MersenneTwister.h"
#include "packets/cPacket_SpawnMob.h"
#include "packets/cPacket_EntityLook.h"
@@ -64,7 +65,8 @@ cMonster::cMonster()
LOG("In state: %s",GetState());
m_Health = 10;
- int RandVal = rand() % 4;
+ MTRand r1;
+ int RandVal = r1.randInt() % 4;
if( RandVal == 0 )
m_MobType = 90; // Pig
else if( RandVal == 1 )
@@ -418,12 +420,13 @@ void cMonster::EventLosePlayer(){
void cMonster::InStateIdle(float a_Dt) {
idle_interval += a_Dt;
if(idle_interval > 1) { //at this interval the results are predictable
- int rem = rand()%6 + 1;
+ MTRand r1;
+ int rem = r1.randInt()%6 + 1;
//LOG("Moving: int: %3.3f rem: %i",idle_interval,rem);
idle_interval = 0;
Vector3f Dist;
- Dist.x = (float)((rand()%11)-5);
- Dist.z = (float)((rand()%11)-5);
+ Dist.x = (float)((r1.randInt()%11)-5);
+ Dist.z = (float)((r1.randInt()%11)-5);
if( Dist.SqrLength() > 2 && rem >= 3)
{
m_Destination->x = (float)(m_Pos->x + Dist.x);
@@ -581,5 +584,6 @@ void cMonster::DropItem(ENUM_ITEM_ID a_Item, unsigned int a_Count)
void cMonster::RandomDropItem(ENUM_ITEM_ID a_Item, unsigned int a_Min, unsigned int a_Max)
{
- return cMonster::DropItem(a_Item, rand() % (a_Max + 1) + a_Min);
+ MTRand r1;
+ return cMonster::DropItem(a_Item, r1.randInt() % (a_Max + 1) + a_Min);
} \ No newline at end of file