@@ -77,31 +77,14 @@ int CCreature::getQuantityID(const int & quantity)
return 8;
}
-int CCreature::estimateCreatureCount(int countID)
+int CCreature::estimateCreatureCount(unsigned int countID)
{
- switch(countID)
- {
- case 0:
- return 3;
- case 1:
- return 8;
- case 2:
- return 15;
- case 3:
- return 35;
- case 4:
- return 75;
- case 5:
- return 175;
- case 6:
- return 375;
- case 7:
- return 750;
- case 8:
- return 2500;
- default:
+ static const int creature_count[] = { 3, 8, 15, 35, 75, 175, 375, 750, 2500 };
+
+ if (countID > 8)
assert("Wrong countID!");
- }
+ return creature_count[countID];
bool CCreature::isDoubleWide() const
@@ -58,7 +58,7 @@ public:
bool isEvil () const;
si32 maxAmount(const std::vector<si32> &res) const; //how many creatures can be bought
static int getQuantityID(const int & quantity); //0 - a few, 1 - several, 2 - pack, 3 - lots, 4 - horde, 5 - throng, 6 - swarm, 7 - zounds, 8 - legion
- static int estimateCreatureCount(int countID); //reverse version of above function, returns middle of range
+ static int estimateCreatureCount(unsigned int countID); //reverse version of above function, returns middle of range
bool isMyUpgrade(const CCreature *anotherCre) const;
bool valid() const;