From 7c750914f0ddd0fec414e8690b10145ed61e7fa9 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 5 Feb 2014 18:10:08 +0100 Subject: Improvements: Adds a function in cRoot that allows you to reload all the groups permissions. Note: Players don't automatically load their new permissions. You can use cPlayer::LoadPermissionsFromDisk for that. --- src/Group.cpp | 31 +++++++++++++++++++++++++++---- src/Group.h | 24 +++++++++++++----------- src/GroupManager.cpp | 23 ++++++++++++++++------- src/GroupManager.h | 1 + src/Root.cpp | 9 +++++++++ src/Root.h | 3 +++ 6 files changed, 69 insertions(+), 22 deletions(-) diff --git a/src/Group.cpp b/src/Group.cpp index 448d29d87..cc42c55a1 100644 --- a/src/Group.cpp +++ b/src/Group.cpp @@ -3,19 +3,34 @@ #include "Group.h" -void cGroup::AddCommand( std::string a_Command ) + + + + +void cGroup::AddCommand( AString a_Command ) { m_Commands[ a_Command ] = true; } -void cGroup::AddPermission( std::string a_Permission ) + + + + +void cGroup::AddPermission( AString a_Permission ) { m_Permissions[ a_Permission ] = true; } -bool cGroup::HasCommand( std::string a_Command ) + + + + +bool cGroup::HasCommand( AString a_Command ) { - if( m_Commands.find("*") != m_Commands.end() ) return true; + if( m_Commands.find("*") != m_Commands.end() ) + { + return true; + } CommandMap::iterator itr = m_Commands.find( a_Command ); if( itr != m_Commands.end() ) @@ -34,4 +49,12 @@ void cGroup::InheritFrom( cGroup* a_Group ) { m_Inherits.remove( a_Group ); m_Inherits.push_back( a_Group ); +} + + + + +void cGroup::ClearPermission() +{ + m_Permissions.clear(); } \ No newline at end of file diff --git a/src/Group.h b/src/Group.h index 65ee1a60a..3299aecbc 100644 --- a/src/Group.h +++ b/src/Group.h @@ -11,19 +11,21 @@ public: // tolua_export cGroup() {} ~cGroup() {} - void SetName( std::string a_Name ) { m_Name = a_Name; } // tolua_export - const std::string & GetName() const { return m_Name; } // tolua_export - void SetColor( std::string a_Color ) { m_Color = a_Color; } // tolua_export - void AddCommand( std::string a_Command ); // tolua_export - void AddPermission( std::string a_Permission ); // tolua_export - void InheritFrom( cGroup* a_Group ); // tolua_export + void SetName( AString a_Name ) { m_Name = a_Name; } // tolua_export + const AString & GetName() const { return m_Name; } // tolua_export + void SetColor( AString a_Color ) { m_Color = a_Color; } // tolua_export + void AddCommand( AString a_Command ); // tolua_export + void AddPermission( AString a_Permission ); // tolua_export + void InheritFrom( cGroup* a_Group ); // tolua_export - bool HasCommand( std::string a_Command ); // tolua_export + bool HasCommand( AString a_Command ); // tolua_export - typedef std::map< std::string, bool > PermissionMap; + typedef std::map< AString, bool > PermissionMap; const PermissionMap & GetPermissions() const { return m_Permissions; } - typedef std::map< std::string, bool > CommandMap; + void ClearPermission(void); + + typedef std::map< AString, bool > CommandMap; const CommandMap & GetCommands() const { return m_Commands; } const AString & GetColor() const { return m_Color; } // tolua_export @@ -31,8 +33,8 @@ public: // tolua_export typedef std::list< cGroup* > GroupList; const GroupList & GetInherits() const { return m_Inherits; } private: - std::string m_Name; - std::string m_Color; + AString m_Name; + AString m_Color; PermissionMap m_Permissions; CommandMap m_Commands; diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index d5567d91e..99befa0ff 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -44,6 +44,18 @@ cGroupManager::cGroupManager() : m_pState( new sGroupManagerState ) { LOGD("-- Loading Groups --"); + + LoadGroups(); + + LOGD("-- Groups Successfully Loaded --"); +} + + + + + +void cGroupManager::LoadGroups() +{ cIniFile IniFile; if (!IniFile.ReadFile("groups.ini")) { @@ -71,8 +83,10 @@ cGroupManager::cGroupManager() unsigned int NumKeys = IniFile.GetNumKeys(); for (size_t i = 0; i < NumKeys; i++) { - std::string KeyName = IniFile.GetKeyName( i ); + AString KeyName = IniFile.GetKeyName( i ); cGroup* Group = GetGroup( KeyName.c_str() ); + + Group->ClearPermission(); // Needed in case the groups are reloaded. LOGD("Loading group: %s", KeyName.c_str() ); @@ -107,7 +121,7 @@ cGroupManager::cGroupManager() } } - std::string Groups = IniFile.GetValue(KeyName, "Inherits", ""); + AString Groups = IniFile.GetValue(KeyName, "Inherits", ""); if (!Groups.empty()) { AStringVector Split = StringSplitAndTrim(Groups, ","); @@ -117,13 +131,8 @@ cGroupManager::cGroupManager() } } } - LOGD("-- Groups Successfully Loaded --"); } - - - - cGroup* cGroupManager::GetGroup( const AString & a_Name ) { GroupMap::iterator itr = m_pState->Groups.find( a_Name ); diff --git a/src/GroupManager.h b/src/GroupManager.h index d911f976c..02a58fe4e 100644 --- a/src/GroupManager.h +++ b/src/GroupManager.h @@ -15,6 +15,7 @@ class cGroupManager { public: cGroup * GetGroup(const AString & a_Name); + void LoadGroups(void); private: friend class cRoot; diff --git a/src/Root.cpp b/src/Root.cpp index 883bfe76e..5d1b2ebe2 100644 --- a/src/Root.cpp +++ b/src/Root.cpp @@ -536,6 +536,15 @@ void cRoot::SaveAllChunks(void) +void cRoot::ReloadGroups(void) +{ + m_GroupManager->LoadGroups(); +} + + + + + void cRoot::BroadcastChat(const AString & a_Message) { for (WorldMap::iterator itr = m_WorldsByName.begin(), end = m_WorldsByName.end(); itr != end; ++itr) diff --git a/src/Root.h b/src/Root.h index c59afc810..71ee2e671 100644 --- a/src/Root.h +++ b/src/Root.h @@ -98,6 +98,9 @@ public: /// Saves all chunks in all worlds void SaveAllChunks(void); // tolua_export + /// Reloads all the groups + void ReloadGroups(void); // tolua_export + /// Sends a chat message to all connected clients (in all worlds) void BroadcastChat(const AString & a_Message); // tolua_export -- cgit v1.2.3 From d6142b53f30dd212bea8f7daef3915e189791df5 Mon Sep 17 00:00:00 2001 From: STRWarrior Date: Wed, 5 Feb 2014 18:14:51 +0100 Subject: Forgot extra lines. --- src/GroupManager.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/GroupManager.cpp b/src/GroupManager.cpp index 99befa0ff..723b86f94 100644 --- a/src/GroupManager.cpp +++ b/src/GroupManager.cpp @@ -133,6 +133,10 @@ void cGroupManager::LoadGroups() } } + + + + cGroup* cGroupManager::GetGroup( const AString & a_Name ) { GroupMap::iterator itr = m_pState->Groups.find( a_Name ); -- cgit v1.2.3 From 8ba6f731699465aa13818e307af7b9f001d3767e Mon Sep 17 00:00:00 2001 From: Tycho Date: Wed, 5 Feb 2014 09:43:49 -0800 Subject: Fixed most of the reordering warnings --- src/Bindings/ManualBindings.cpp | 4 ++-- src/Crypto.cpp | 8 ++++---- src/Entities/Entity.cpp | 4 ++-- src/Entities/Floater.cpp | 4 ++-- src/Entities/Minecart.cpp | 10 +++++----- src/Entities/Pickup.cpp | 4 ++-- src/Item.h | 8 ++++---- src/Mobs/Monster.cpp | 8 ++++---- src/Mobs/Villager.cpp | 4 ++-- src/Scoreboard.cpp | 2 +- src/Simulator/RedstoneSimulator.cpp | 6 +++--- src/World.cpp | 4 ++-- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/src/Bindings/ManualBindings.cpp b/src/Bindings/ManualBindings.cpp index dbaf32756..9ebdc4b22 100644 --- a/src/Bindings/ManualBindings.cpp +++ b/src/Bindings/ManualBindings.cpp @@ -1593,9 +1593,9 @@ static int tolua_cPluginManager_CallPlugin(lua_State * tolua_S) int m_NumReturns; cCallback(const AString & a_FunctionName, cLuaState & a_SrcLuaState) : + m_NumReturns(0), m_FunctionName(a_FunctionName), - m_SrcLuaState(a_SrcLuaState), - m_NumReturns(0) + m_SrcLuaState(a_SrcLuaState) { } protected: diff --git a/src/Crypto.cpp b/src/Crypto.cpp index 7a06d7fa3..26500f263 100644 --- a/src/Crypto.cpp +++ b/src/Crypto.cpp @@ -308,8 +308,8 @@ void cPublicKey::InitRnd(void) // cAESCFBDecryptor: cAESCFBDecryptor::cAESCFBDecryptor(void) : - m_IsValid(false), - m_IVOffset(0) + m_IVOffset(0), + m_IsValid(false) { } @@ -366,8 +366,8 @@ void cAESCFBDecryptor::ProcessData(Byte * a_DecryptedOut, const Byte * a_Encrypt // cAESCFBEncryptor: cAESCFBEncryptor::cAESCFBEncryptor(void) : - m_IsValid(false), - m_IVOffset(0) + m_IVOffset(0), + m_IsValid(false) { } diff --git a/src/Entities/Entity.cpp b/src/Entities/Entity.cpp index 08780ca8b..8554ab2a5 100644 --- a/src/Entities/Entity.cpp +++ b/src/Entities/Entity.cpp @@ -50,6 +50,8 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_TicksSinceLastFireDamage(0) , m_TicksLeftBurning(0) , m_TicksSinceLastVoidDamage(0) + , m_IsSwimming(false) + , m_IsSubmerged(false) , m_HeadYaw( 0.0 ) , m_Rot(0.0, 0.0, 0.0) , m_Pos(a_X, a_Y, a_Z) @@ -57,8 +59,6 @@ cEntity::cEntity(eEntityType a_EntityType, double a_X, double a_Y, double a_Z, d , m_Mass (0.001) // Default 1g , m_Width(a_Width) , m_Height(a_Height) - , m_IsSubmerged(false) - , m_IsSwimming(false) { cCSLock Lock(m_CSCount); m_EntityCount++; diff --git a/src/Entities/Floater.cpp b/src/Entities/Floater.cpp index 38160a30e..b910c3769 100644 --- a/src/Entities/Floater.cpp +++ b/src/Entities/Floater.cpp @@ -103,10 +103,10 @@ protected: cFloater::cFloater(double a_X, double a_Y, double a_Z, Vector3d a_Speed, int a_PlayerID, int a_CountDownTime) : cEntity(etFloater, a_X, a_Y, a_Z, 0.2, 0.2), - m_PickupCountDown(0), - m_PlayerID(a_PlayerID), m_CanPickupItem(false), + m_PickupCountDown(0), m_CountDownTime(a_CountDownTime), + m_PlayerID(a_PlayerID), m_AttachedMobID(-1) { SetSpeed(a_Speed); diff --git a/src/Entities/Minecart.cpp b/src/Entities/Minecart.cpp index a650927b1..d854906b7 100644 --- a/src/Entities/Minecart.cpp +++ b/src/Entities/Minecart.cpp @@ -24,11 +24,11 @@ class cMinecartCollisionCallback : { public: cMinecartCollisionCallback(Vector3d a_Pos, double a_Height, double a_Width, int a_UniqueID, int a_AttacheeUniqueID) : + m_DoesInteserct(false), + m_CollidedEntityPos(0, 0, 0), m_Pos(a_Pos), m_Height(a_Height), m_Width(a_Width), - m_DoesInteserct(false), - m_CollidedEntityPos(0, 0, 0), m_UniqueID(a_UniqueID), m_AttacheeUniqueID(a_AttacheeUniqueID) { @@ -1057,8 +1057,8 @@ void cMinecartWithChest::OnRightClicked(cPlayer & a_Player) cMinecartWithFurnace::cMinecartWithFurnace(double a_X, double a_Y, double a_Z) : super(mpFurnace, a_X, a_Y, a_Z), - m_IsFueled(false), - m_FueledTimeLeft(-1) + m_FueledTimeLeft(-1), + m_IsFueled(false) { } @@ -1137,4 +1137,4 @@ cMinecartWithHopper::cMinecartWithHopper(double a_X, double a_Y, double a_Z) : } // TODO: Make it suck up blocks and travel further than any other cart and physics and put and take blocks -// AND AVARYTHING!! \ No newline at end of file +// AND AVARYTHING!! diff --git a/src/Entities/Pickup.cpp b/src/Entities/Pickup.cpp index bfe162b69..c5503c16a 100644 --- a/src/Entities/Pickup.cpp +++ b/src/Entities/Pickup.cpp @@ -22,9 +22,9 @@ class cPickupCombiningCallback : { public: cPickupCombiningCallback(Vector3d a_Position, cPickup * a_Pickup) : + m_FoundMatchingPickup(false), m_Position(a_Position), - m_Pickup(a_Pickup), - m_FoundMatchingPickup(false) + m_Pickup(a_Pickup) { } diff --git a/src/Item.h b/src/Item.h index 727965112..1afb5938a 100644 --- a/src/Item.h +++ b/src/Item.h @@ -55,9 +55,9 @@ public: m_ItemType (a_ItemType), m_ItemCount (a_ItemCount), m_ItemDamage (a_ItemDamage), - m_Enchantments(a_Enchantments), m_CustomName (a_CustomName), - m_Lore (a_Lore) + m_Lore (a_Lore), + m_Enchantments(a_Enchantments) { if (!IsValidItem(m_ItemType)) { @@ -75,9 +75,9 @@ public: m_ItemType (a_CopyFrom.m_ItemType), m_ItemCount (a_CopyFrom.m_ItemCount), m_ItemDamage (a_CopyFrom.m_ItemDamage), - m_Enchantments(a_CopyFrom.m_Enchantments), m_CustomName (a_CopyFrom.m_CustomName), - m_Lore (a_CopyFrom.m_Lore) + m_Lore (a_CopyFrom.m_Lore), + m_Enchantments(a_CopyFrom.m_Enchantments) { } diff --git a/src/Mobs/Monster.cpp b/src/Mobs/Monster.cpp index 283ef36e6..1b9bfaa79 100644 --- a/src/Mobs/Monster.cpp +++ b/src/Mobs/Monster.cpp @@ -69,20 +69,20 @@ cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString : super(etMonster, a_Width, a_Height) , m_EMState(IDLE) , m_EMPersonality(AGGRESSIVE) - , m_SightDistance(25) , m_Target(NULL) - , m_AttackRate(3) - , m_IdleInterval(0) , m_bMovingToDestination(false) + , m_LastGroundHeight(POSY_TOINT) + , m_IdleInterval(0) , m_DestroyTimer(0) , m_MobType(a_MobType) , m_SoundHurt(a_SoundHurt) , m_SoundDeath(a_SoundDeath) + , m_AttackRate(3) , m_AttackDamage(1) , m_AttackRange(2) , m_AttackInterval(0) + , m_SightDistance(25) , m_BurnsInDaylight(false) - , m_LastGroundHeight(POSY_TOINT) { if (!a_ConfigName.empty()) { diff --git a/src/Mobs/Villager.cpp b/src/Mobs/Villager.cpp index 08e5e4315..09a6e2d09 100644 --- a/src/Mobs/Villager.cpp +++ b/src/Mobs/Villager.cpp @@ -13,9 +13,9 @@ cVillager::cVillager(eVillagerType VillagerType) : super("Villager", mtVillager, "", "", 0.6, 1.8), + m_ActionCountDown(-1), m_Type(VillagerType), - m_VillagerAction(false), - m_ActionCountDown(-1) + m_VillagerAction(false) { } diff --git a/src/Scoreboard.cpp b/src/Scoreboard.cpp index b2edd613b..61ecac5b7 100644 --- a/src/Scoreboard.cpp +++ b/src/Scoreboard.cpp @@ -197,8 +197,8 @@ cTeam::cTeam(const AString & a_Name, const AString & a_DisplayName, const AString & a_Prefix, const AString & a_Suffix) : m_AllowsFriendlyFire(true) , m_CanSeeFriendlyInvisible(false) - , m_Name(a_Name) , m_DisplayName(a_DisplayName) + , m_Name(a_Name) , m_Prefix(a_Prefix) , m_Suffix(a_Suffix) {} diff --git a/src/Simulator/RedstoneSimulator.cpp b/src/Simulator/RedstoneSimulator.cpp index 6b7ae3196..298175ad7 100644 --- a/src/Simulator/RedstoneSimulator.cpp +++ b/src/Simulator/RedstoneSimulator.cpp @@ -946,11 +946,11 @@ void cRedstoneSimulator::HandlePressurePlate(int a_BlockX, int a_BlockY, int a_B { public: cWoodenPressurePlateCallback(int a_BlockX, int a_BlockY, int a_BlockZ, cWorld * a_World) : + m_Entity(NULL), + m_World(a_World), m_X(a_BlockX), m_Y(a_BlockY), - m_Z(a_BlockZ), - m_World(a_World), - m_Entity(NULL) + m_Z(a_BlockZ) { } diff --git a/src/World.cpp b/src/World.cpp index f9a6e7776..892e04d63 100644 --- a/src/World.cpp +++ b/src/World.cpp @@ -247,9 +247,9 @@ cWorld::cWorld(const AString & a_WorldName) : m_SkyDarkness(0), m_Weather(eWeather_Sunny), m_WeatherInterval(24000), // Guaranteed 1 day of sunshine at server start :) + m_Scoreboard(this), m_GeneratorCallbacks(*this), - m_TickThread(*this), - m_Scoreboard(this) + m_TickThread(*this) { LOGD("cWorld::cWorld(\"%s\")", a_WorldName.c_str()); -- cgit v1.2.3