summaryrefslogtreecommitdiffstats
path: root/source/Items/ItemHandler.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-07-28 19:15:03 +0200
committermadmaxoft <github@xoft.cz>2013-07-28 19:15:03 +0200
commit4746d2251c6204118e710c818d78b89c356a7427 (patch)
tree2573e0b5e70b04aebc35d5da034c8449ff696f3d /source/Items/ItemHandler.cpp
parentProtoProxy now properly waits for both sides to establish encryption (diff)
downloadcuberite-4746d2251c6204118e710c818d78b89c356a7427.tar
cuberite-4746d2251c6204118e710c818d78b89c356a7427.tar.gz
cuberite-4746d2251c6204118e710c818d78b89c356a7427.tar.bz2
cuberite-4746d2251c6204118e710c818d78b89c356a7427.tar.lz
cuberite-4746d2251c6204118e710c818d78b89c356a7427.tar.xz
cuberite-4746d2251c6204118e710c818d78b89c356a7427.tar.zst
cuberite-4746d2251c6204118e710c818d78b89c356a7427.zip
Diffstat (limited to '')
-rw-r--r--source/Items/ItemHandler.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/source/Items/ItemHandler.cpp b/source/Items/ItemHandler.cpp
index d99457029..acb6b6371 100644
--- a/source/Items/ItemHandler.cpp
+++ b/source/Items/ItemHandler.cpp
@@ -4,6 +4,7 @@
#include "../Item.h"
#include "../World.h"
#include "../Player.h"
+#include "../FastRandom.h"
// Handlers:
#include "ItemBed.h"
@@ -465,15 +466,17 @@ bool cItemHandler::EatItem(cPlayer * a_Player, cItem * a_Item)
{
FoodInfo Info = GetFoodInfo();
- if(Info.FoodLevel > 0 || Info.Saturation > 0.f)
+ if ((Info.FoodLevel > 0) || (Info.Saturation > 0.f))
{
bool Success = a_Player->Feed(Info.FoodLevel, Info.Saturation);
- if(Success && Info.PoisionChance > 0)
+
+ // If consumed and there's chance of foodpoisoning, do it:
+ if (Success && (Info.PoisonChance > 0))
{
- MTRand r1;
- if((r1.randInt(100) - Info.PoisionChance) <= 0)
- { //Unlucky guy :D
- //TODO: Make player ill
+ cFastRandom r1;
+ if ((r1.NextInt(100, a_Player->GetUniqueID()) - Info.PoisonChance) <= 0)
+ {
+ a_Player->FoodPoison(300);
}
}