1
0

Added an option to disable/enable PVP on a per world basis

git-svn-id: http://mc-server.googlecode.com/svn/trunk@944 0a769ca7-a7f5-676a-18bf-c427514a06d6
This commit is contained in:
faketruth 2012-10-10 19:46:12 +00:00
parent a038425736
commit ae5975e674
3 changed files with 13 additions and 1 deletions

View File

@ -887,6 +887,15 @@ void cClientHandle::HandleUseEntity(int a_TargetEntityID, bool a_IsLeftClick)
{ {
virtual bool Item(cEntity * a_Entity) override virtual bool Item(cEntity * a_Entity) override
{ {
if (a_Entity->GetWorld()->IsPVPEnabled() == false)
{
// PVP is disabled
if (a_Entity->IsA("cPlayer") && Instigator->IsA("cPlayer"))
{
// Player is hurting another player which is not allowed when PVP is disabled so ignore it
return true;
}
}
if (a_Entity->IsA("cPawn")) if (a_Entity->IsA("cPawn"))
{ {
reinterpret_cast<cPawn *>(a_Entity)->TakeDamage(Damage, Instigator); reinterpret_cast<cPawn *>(a_Entity)->TakeDamage(Damage, Instigator);

View File

@ -250,6 +250,7 @@ cWorld::cWorld( const AString & a_WorldName )
m_IsPumpkinBonemealable = IniFile.GetValueSetB("Plants", "IsPumpkinBonemealable", false); m_IsPumpkinBonemealable = IniFile.GetValueSetB("Plants", "IsPumpkinBonemealable", false);
m_IsSugarcaneBonemealable = IniFile.GetValueSetB("Plants", "IsSugarcaneBonemealable", false); m_IsSugarcaneBonemealable = IniFile.GetValueSetB("Plants", "IsSugarcaneBonemealable", false);
m_IsCactusBonemealable = IniFile.GetValueSetB("Plants", "IsCactusBonemealable", false); m_IsCactusBonemealable = IniFile.GetValueSetB("Plants", "IsCactusBonemealable", false);
m_bEnabledPVP = IniFile.GetValueSetB("PVP", "Enabled", true);
m_GameMode = (eGameMode)IniFile.GetValueSetI("GameMode", "GameMode", m_GameMode ); m_GameMode = (eGameMode)IniFile.GetValueSetI("GameMode", "GameMode", m_GameMode );

View File

@ -68,6 +68,7 @@ public:
long long GetWorldTime(void) const { return m_WorldTime; } //tolua_export long long GetWorldTime(void) const { return m_WorldTime; } //tolua_export
eGameMode GetGameMode(void) const { return m_GameMode; } //tolua_export eGameMode GetGameMode(void) const { return m_GameMode; } //tolua_export
bool IsPVPEnabled(void) const { return m_bEnabledPVP; } //tolua_export
void SetWorldTime(long long a_WorldTime) { m_WorldTime = a_WorldTime; } //tolua_export void SetWorldTime(long long a_WorldTime) { m_WorldTime = a_WorldTime; } //tolua_export
@ -416,6 +417,7 @@ private:
long long m_WorldTime; // Time in seconds*20, this is sent to clients (is wrapped) long long m_WorldTime; // Time in seconds*20, this is sent to clients (is wrapped)
unsigned long long CurrentTick; unsigned long long CurrentTick;
eGameMode m_GameMode; eGameMode m_GameMode;
bool m_bEnabledPVP;
float m_WorldTimeFraction; // When this > 1.f m_WorldTime is incremented by 20 float m_WorldTimeFraction; // When this > 1.f m_WorldTime is incremented by 20
// The cRedstone class simulates redstone and needs access to m_RSList // The cRedstone class simulates redstone and needs access to m_RSList