1
0

Fix switch warnings (#4013)

* Fix switch warnings
  * Fix a variety of -Wswitch and -Wswitch-enum warnings
  * Remove unneeded -Wno-error flags

* Reorganise some eMonsterType switches
  * Alpha sort eMonsterType cases in WriteMobMetadata
    and in cNBTChunkSerializer::AddMonsterEntity
  * List all mob types in protocol 1.12 and NBTChunkSerializer

* cStructGenTrees::GetNumTrees: remove switch default

* cWSSAnvil::LoadOldMinecartFromNBT: Log unhandled minecart type
This commit is contained in:
peterbell10
2017-09-14 09:48:57 +01:00
committed by Alexander Harkness
parent e24186bb13
commit 307e7aaff5
24 changed files with 357 additions and 322 deletions

View File

@@ -643,6 +643,35 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
m_Writer.AddInt("Size", reinterpret_cast<const cMagmaCube *>(a_Monster)->GetSize());
break;
}
case mtOcelot:
{
const auto *Ocelot = reinterpret_cast<const cOcelot *>(a_Monster);
if (!Ocelot->GetOwnerName().empty())
{
m_Writer.AddString("Owner", Ocelot->GetOwnerName());
}
if (!Ocelot->GetOwnerUUID().IsNil())
{
m_Writer.AddString("OwnerUUID", Ocelot->GetOwnerUUID().ToShortString());
}
m_Writer.AddByte("Sitting", Ocelot->IsSitting() ? 1 : 0);
m_Writer.AddInt("CatType", Ocelot->GetOcelotType());
m_Writer.AddInt("Age", Ocelot->GetAge());
break;
}
case mtPig:
{
m_Writer.AddInt("Age", reinterpret_cast<const cPig *>(a_Monster)->GetAge());
break;
}
case mtRabbit:
{
const cRabbit * Rabbit = reinterpret_cast<const cRabbit *>(a_Monster);
m_Writer.AddInt("RabbitType", static_cast<Int32>(Rabbit->GetRabbitType()));
m_Writer.AddInt("MoreCarrotTicks", Rabbit->GetMoreCarrotTicks());
m_Writer.AddInt("Age", Rabbit->GetAge());
break;
}
case mtSheep:
{
const cSheep *Sheep = reinterpret_cast<const cSheep *>(a_Monster);
@@ -703,36 +732,6 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
m_Writer.AddInt("Age", reinterpret_cast<const cZombiePigman *>(a_Monster)->GetAge());
break;
}
case mtOcelot:
{
const auto *Ocelot = reinterpret_cast<const cOcelot *>(a_Monster);
if (!Ocelot->GetOwnerName().empty())
{
m_Writer.AddString("Owner", Ocelot->GetOwnerName());
}
if (!Ocelot->GetOwnerUUID().IsNil())
{
m_Writer.AddString("OwnerUUID", Ocelot->GetOwnerUUID().ToShortString());
}
m_Writer.AddByte("Sitting", Ocelot->IsSitting() ? 1 : 0);
m_Writer.AddInt ("CatType", Ocelot->GetOcelotType());
m_Writer.AddInt ("Age", Ocelot->GetAge());
break;
}
case mtPig:
{
m_Writer.AddInt("Age", reinterpret_cast<const cPig *>(a_Monster)->GetAge());
break;
}
case mtRabbit:
{
const cRabbit * Rabbit = reinterpret_cast<const cRabbit *>(a_Monster);
m_Writer.AddInt("RabbitType", static_cast<Int32>(Rabbit->GetRabbitType()));
m_Writer.AddInt("MoreCarrotTicks", Rabbit->GetMoreCarrotTicks());
m_Writer.AddInt("Age", Rabbit->GetAge());
break;
}
case mtInvalidType:
case mtBlaze:
case mtCaveSpider:
case mtChicken:
@@ -752,6 +751,11 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
// Other mobs have no special tags.
break;
}
case mtInvalidType:
{
ASSERT(!"cNBTChunkSerializer::AddMonsterEntity: Recieved mob of invalid type");
break;
}
}
m_Writer.EndCompound();
}