summaryrefslogtreecommitdiffstats
path: root/source/Items/ItemHandler.cpp
diff options
context:
space:
mode:
authormadmaxoft <github@xoft.cz>2013-07-29 09:57:34 +0200
committermadmaxoft <github@xoft.cz>2013-07-29 09:57:34 +0200
commit5530178aad3fa1a3061962d47d77b627ab5ceae3 (patch)
tree61ee7896061b4ef92877c120d9f5e917a6c5c924 /source/Items/ItemHandler.cpp
parentMerge pull request #15 from mc-server/webadmin (diff)
parentUpdated the automatic Lua bindings (diff)
downloadcuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar.gz
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar.bz2
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar.lz
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar.xz
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.tar.zst
cuberite-5530178aad3fa1a3061962d47d77b627ab5ceae3.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);
}
}