1
0

Implement horse inventory (#4053)

* Implement horse inventory

* Fix sign conversions

* Add API doc for ItemCategory::IsHorseArmor

* Improve HandleOpenHorseInventory comment and style fixes.
This commit is contained in:
peterbell10
2017-10-21 17:56:09 +01:00
committed by Alexander Harkness
parent e585595ae6
commit 0bacda3269
15 changed files with 473 additions and 27 deletions

View File

@@ -5,6 +5,7 @@
#include "Player.h"
#include "Mobs/Wolf.h"
#include "Mobs/Horse.h"
#include "../BoundingBox.h"
#include "../ChatColor.h"
#include "../Server.h"
@@ -2202,6 +2203,35 @@ bool cPlayer::LoadFromFile(const AString & a_FileName, cWorldPtr & a_World)
void cPlayer::OpenHorseInventory()
{
if (
(m_AttachedTo == nullptr) ||
!m_AttachedTo->IsMob()
)
{
return;
}
auto & Mob = static_cast<cMonster &>(*m_AttachedTo);
if (Mob.GetMobType() != mtHorse)
{
return;
}
auto & Horse = static_cast<cHorse &>(Mob);
// The client sends requests for untame horses as well but shouldn't actually open
if (Horse.IsTame())
{
Horse.PlayerOpenWindow(*this);
}
}
bool cPlayer::SaveToDisk()
{
cFile::CreateFolder(FILE_IO_PREFIX + AString("players/")); // Create the "players" folder, if it doesn't exist yet (#1268)