From c7fa610be3b6e072d3da4611f6de72390ebbf446 Mon Sep 17 00:00:00 2001 From: "mtilden@gmail.com" Date: Mon, 26 Dec 2011 09:09:47 +0000 Subject: - Linux compatible fixes including updated makefile - Mersenne Twister still says uint32 but it's now signed for compatibility with random uses needing negative values - Server seed is sent to clients, but needs to be able to be signed long long later on for authentic reasons - Protocol Version is required to match to ensure client compatibility, this should probably have a settings.ini check as well as store the value there git-svn-id: http://mc-server.googlecode.com/svn/trunk@121 0a769ca7-a7f5-676a-18bf-c427514a06d6 --- source/cMonster.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) (limited to 'source/cMonster.cpp') 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 -- cgit v1.2.3