1
0
Fork 0

Reimplemented cMonster::FamilyFromType() as a simple switch (duh!)

This commit is contained in:
madmaxoft 2013-10-20 14:15:55 +02:00
parent 6075f7cecd
commit d8576a7953
1 changed files with 26 additions and 37 deletions

View File

@ -570,45 +570,34 @@ cMonster::eType cMonster::StringToMobType(const AString & a_Name)
cMonster::eFamily cMonster::FamilyFromType(eType a_Type) cMonster::eFamily cMonster::FamilyFromType(eType a_Type)
{ {
static const struct switch (a_Type)
{ {
eType m_Type; case mtBat: return mfAmbient;
eFamily m_Family; case mtBlaze: return mfHostile;
} TypeMap[] = case mtCaveSpider: return mfHostile;
{ case mtChicken: return mfPassive;
{mtBat, mfAmbient}, case mtCow: return mfPassive;
{mtBlaze, mfHostile}, case mtCreeper: return mfHostile;
{mtCaveSpider, mfHostile}, case mtEnderman: return mfHostile;
{mtChicken, mfPassive}, case mtGhast: return mfHostile;
{mtCow, mfPassive}, case mtHorse: return mfPassive;
{mtCreeper, mfHostile}, case mtMagmaCube: return mfHostile;
{mtEnderman, mfHostile}, case mtMooshroom: return mfHostile;
{mtGhast, mfHostile}, case mtOcelot: return mfHostile;
{mtHorse, mfPassive}, case mtPig: return mfPassive;
{mtMagmaCube, mfHostile}, case mtSheep: return mfPassive;
{mtMooshroom, mfHostile}, case mtSilverfish: return mfHostile;
{mtOcelot, mfHostile}, case mtSkeleton: return mfHostile;
{mtPig, mfPassive}, case mtSlime: return mfHostile;
{mtSheep, mfPassive}, case mtSpider: return mfHostile;
{mtSilverfish, mfHostile}, case mtSquid: return mfWater;
{mtSkeleton, mfHostile}, case mtVillager: return mfPassive;
{mtSlime, mfHostile}, case mtWitch: return mfHostile;
{mtSpider, mfHostile}, case mtWolf: return mfHostile;
{mtSquid, mfWater}, case mtZombie: return mfHostile;
{mtVillager, mfPassive}, case mtZombiePigman: return mfHostile;
{mtWitch, mfHostile},
{mtWolf, mfHostile},
{mtZombie, mfHostile},
{mtZombiePigman, mfHostile},
} ; } ;
ASSERT(!"Unhandled mob type");
for (int i = 0; i < ARRAYCOUNT(TypeMap); i++)
{
if (TypeMap[i].m_Type == a_Type)
{
return TypeMap[i].m_Family;
}
}
return mfMaxplusone; return mfMaxplusone;
} }