From d8576a79537029bc40ff9a125e9ada4739ce76bb Mon Sep 17 00:00:00 2001 From: madmaxoft Date: Sun, 20 Oct 2013 14:15:55 +0200 Subject: Reimplemented cMonster::FamilyFromType() as a simple switch (duh!) --- source/Mobs/Monster.cpp | 65 ++++++++++++++++++++----------------------------- 1 file changed, 27 insertions(+), 38 deletions(-) (limited to 'source/Mobs') diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp index c5b116db4..599aa9cfc 100644 --- a/source/Mobs/Monster.cpp +++ b/source/Mobs/Monster.cpp @@ -570,45 +570,34 @@ cMonster::eType cMonster::StringToMobType(const AString & a_Name) cMonster::eFamily cMonster::FamilyFromType(eType a_Type) { - static const struct - { - eType m_Type; - eFamily m_Family; - } TypeMap[] = - { - {mtBat, mfAmbient}, - {mtBlaze, mfHostile}, - {mtCaveSpider, mfHostile}, - {mtChicken, mfPassive}, - {mtCow, mfPassive}, - {mtCreeper, mfHostile}, - {mtEnderman, mfHostile}, - {mtGhast, mfHostile}, - {mtHorse, mfPassive}, - {mtMagmaCube, mfHostile}, - {mtMooshroom, mfHostile}, - {mtOcelot, mfHostile}, - {mtPig, mfPassive}, - {mtSheep, mfPassive}, - {mtSilverfish, mfHostile}, - {mtSkeleton, mfHostile}, - {mtSlime, mfHostile}, - {mtSpider, mfHostile}, - {mtSquid, mfWater}, - {mtVillager, mfPassive}, - {mtWitch, mfHostile}, - {mtWolf, mfHostile}, - {mtZombie, mfHostile}, - {mtZombiePigman, mfHostile}, + switch (a_Type) + { + case mtBat: return mfAmbient; + case mtBlaze: return mfHostile; + case mtCaveSpider: return mfHostile; + case mtChicken: return mfPassive; + case mtCow: return mfPassive; + case mtCreeper: return mfHostile; + case mtEnderman: return mfHostile; + case mtGhast: return mfHostile; + case mtHorse: return mfPassive; + case mtMagmaCube: return mfHostile; + case mtMooshroom: return mfHostile; + case mtOcelot: return mfHostile; + case mtPig: return mfPassive; + case mtSheep: return mfPassive; + case mtSilverfish: return mfHostile; + case mtSkeleton: return mfHostile; + case mtSlime: return mfHostile; + case mtSpider: return mfHostile; + case mtSquid: return mfWater; + case mtVillager: return mfPassive; + case mtWitch: return mfHostile; + case mtWolf: return mfHostile; + case mtZombie: return mfHostile; + case mtZombiePigman: return mfHostile; } ; - - for (int i = 0; i < ARRAYCOUNT(TypeMap); i++) - { - if (TypeMap[i].m_Type == a_Type) - { - return TypeMap[i].m_Family; - } - } + ASSERT(!"Unhandled mob type"); return mfMaxplusone; } -- cgit v1.2.3