summaryrefslogtreecommitdiffstats
path: root/source/cBlockToPickup.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/cBlockToPickup.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 'source/cBlockToPickup.cpp')
-rw-r--r--source/cBlockToPickup.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/source/cBlockToPickup.cpp b/source/cBlockToPickup.cpp
index fb7a898ae..531c9601e 100644
--- a/source/cBlockToPickup.cpp
+++ b/source/cBlockToPickup.cpp
@@ -2,9 +2,11 @@
#include "Defines.h"
#include "BlockID.h"
#include "stdlib.h"
+#include "MersenneTwister.h"
ENUM_ITEM_ID cBlockToPickup::ToPickup( unsigned char a_BlockID, ENUM_ITEM_ID a_UsedItemID )
{
+ MTRand r1;
(void)a_UsedItemID;
switch( a_BlockID )
@@ -28,7 +30,7 @@ ENUM_ITEM_ID cBlockToPickup::ToPickup( unsigned char a_BlockID, ENUM_ITEM_ID a_U
if( a_UsedItemID == E_ITEM_SHEARS )
return E_ITEM_LEAVES;
else
- if(rand() % 5 == 0) return E_ITEM_SAPLING;
+ if(r1.randInt() % 5 == 0) return E_ITEM_SAPLING;
return E_ITEM_EMPTY;
case E_BLOCK_COAL_ORE:
return E_ITEM_COAL;
@@ -67,17 +69,18 @@ ENUM_ITEM_ID cBlockToPickup::ToPickup( unsigned char a_BlockID, ENUM_ITEM_ID a_U
char cBlockToPickup::PickupCount(unsigned char a_BlockID)
{
+ MTRand r1;
switch(a_BlockID)
{
case E_BLOCK_REDSTONE_ORE_GLOWING:
case E_BLOCK_REDSTONE_ORE:
- return rand() % 2 + 4;
+ return r1.randInt() % 2 + 4;
case E_BLOCK_GLOWSTONE:
- return rand() % 3 + 2;
+ return r1.randInt() % 3 + 2;
case E_BLOCK_MELON:
- return rand() % 8 + 3;
+ return r1.randInt() % 8 + 3;
case E_BLOCK_LAPIS_ORE:
- return rand() % 5 + 4;
+ return r1.randInt() % 5 + 4;
default:
return 1;
}