From dba672361164dc5dc5f94d24bde3176c7de89d4c Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 2 Aug 2014 22:42:53 -0700 Subject: Player.cpp: change unnamed enum to constant integers --- src/Entities/Player.cpp | 2 +- src/Entities/Player.h | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 608316e9a..91bcddca3 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -509,7 +509,7 @@ void cPlayer::Heal(int a_Health) void cPlayer::SetFoodLevel(int a_FoodLevel) { - int FoodLevel = std::max(0, std::min(a_FoodLevel, (int)MAX_FOOD_LEVEL)); + int FoodLevel = Clamp(a_FoodLevel, 0, MAX_FOOD_LEVEL); if (cRoot::Get()->GetPluginManager()->CallHookPlayerFoodLevelChange(*this, FoodLevel)) { diff --git a/src/Entities/Player.h b/src/Entities/Player.h index e26808bfc..f345a0207 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -29,12 +29,13 @@ class cPlayer : typedef cPawn super; public: - enum - { - MAX_HEALTH = 20, - MAX_FOOD_LEVEL = 20, - EATING_TICKS = 30, ///< Number of ticks it takes to eat an item - } ; + static const int MAX_HEALTH = 20; + + static const int MAX_FOOD_LEVEL = 20; + + /** Number of ticks it takes to eat an item */ + static const int EATING_TICKS = 30; + // tolua_end CLASS_PROTODEF(cPlayer) -- cgit v1.2.3 From 92f67789fc24572092a70d582aef22d7ef1dd272 Mon Sep 17 00:00:00 2001 From: archshift Date: Sat, 2 Aug 2014 22:56:08 -0700 Subject: Gave names to unnamed enums --- src/Enchantments.h | 2 +- src/HTTPServer/HTTPMessage.h | 2 +- src/Inventory.h | 4 ++-- src/Protocol/Protocol125.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Enchantments.h b/src/Enchantments.h index 98d7c0d36..824f6aa55 100644 --- a/src/Enchantments.h +++ b/src/Enchantments.h @@ -43,7 +43,7 @@ public: /** Individual enchantment IDs, corresponding to their NBT IDs: http://www.minecraftwiki.net/wiki/Data_Values#Enchantment_IDs */ - enum + enum eEnchantment { enchProtection = 0, enchFireProtection = 1, diff --git a/src/HTTPServer/HTTPMessage.h b/src/HTTPServer/HTTPMessage.h index e402c8ad6..c0667030f 100644 --- a/src/HTTPServer/HTTPMessage.h +++ b/src/HTTPServer/HTTPMessage.h @@ -18,7 +18,7 @@ class cHTTPMessage { public: - enum + enum eStatus { HTTP_OK = 200, HTTP_BAD_REQUEST = 400, diff --git a/src/Inventory.h b/src/Inventory.h index ed134aee4..5628fb0da 100644 --- a/src/Inventory.h +++ b/src/Inventory.h @@ -39,8 +39,8 @@ public: enum { invArmorCount = 4, - invInventoryCount = 9 * 3, - invHotbarCount = 9, + invInventoryCount = 9 * 3, + invHotbarCount = 9, invArmorOffset = 0, invInventoryOffset = invArmorOffset + invArmorCount, diff --git a/src/Protocol/Protocol125.h b/src/Protocol/Protocol125.h index 18efeb079..3adac3055 100644 --- a/src/Protocol/Protocol125.h +++ b/src/Protocol/Protocol125.h @@ -103,7 +103,7 @@ public: protected: /// Results of packet-parsing: - enum + enum eParseResult { PARSE_OK = 1, PARSE_ERROR = -1, -- cgit v1.2.3 From a7eb4032ee32f8299857ccdfc4ad9f45227abb05 Mon Sep 17 00:00:00 2001 From: archshift Date: Sun, 10 Aug 2014 17:13:14 -0700 Subject: Fixed tolua error with static initialization --- src/Entities/Player.cpp | 9 +++++++++ src/Entities/Player.h | 6 +++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/Entities/Player.cpp b/src/Entities/Player.cpp index 91bcddca3..4398a5bf3 100644 --- a/src/Entities/Player.cpp +++ b/src/Entities/Player.cpp @@ -33,6 +33,15 @@ +const int cPlayer::MAX_HEALTH = 20; + +const int cPlayer::MAX_FOOD_LEVEL = 20; + +/** Number of ticks it takes to eat an item */ +const int cPlayer::EATING_TICKS = 30; + + + cPlayer::cPlayer(cClientHandle* a_Client, const AString & a_PlayerName) : diff --git a/src/Entities/Player.h b/src/Entities/Player.h index f345a0207..d3ed1ef9d 100644 --- a/src/Entities/Player.h +++ b/src/Entities/Player.h @@ -29,12 +29,12 @@ class cPlayer : typedef cPawn super; public: - static const int MAX_HEALTH = 20; + static const int MAX_HEALTH; - static const int MAX_FOOD_LEVEL = 20; + static const int MAX_FOOD_LEVEL; /** Number of ticks it takes to eat an item */ - static const int EATING_TICKS = 30; + static const int EATING_TICKS; // tolua_end -- cgit v1.2.3