summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--source/Bindings.cpp83
-rw-r--r--source/Bindings.h2
-rw-r--r--source/MobSpawner.cpp9
-rw-r--r--source/MobTypesManager.cpp188
-rw-r--r--source/MobTypesManager.h58
-rw-r--r--source/Mobs/AggressiveMonster.cpp4
-rw-r--r--source/Mobs/AggressiveMonster.h2
-rw-r--r--source/Mobs/Bat.cpp2
-rw-r--r--source/Mobs/Blaze.cpp2
-rw-r--r--source/Mobs/Cavespider.cpp2
-rw-r--r--source/Mobs/Chicken.cpp2
-rw-r--r--source/Mobs/Cow.cpp2
-rw-r--r--source/Mobs/Creeper.cpp2
-rw-r--r--source/Mobs/EnderDragon.cpp2
-rw-r--r--source/Mobs/Enderman.cpp2
-rw-r--r--source/Mobs/Ghast.cpp2
-rw-r--r--source/Mobs/Giant.cpp2
-rw-r--r--source/Mobs/Horse.cpp2
-rw-r--r--source/Mobs/IronGolem.cpp2
-rw-r--r--source/Mobs/Magmacube.cpp2
-rw-r--r--source/Mobs/Monster.cpp10
-rw-r--r--source/Mobs/Monster.h16
-rw-r--r--source/Mobs/Mooshroom.cpp2
-rw-r--r--source/Mobs/Ocelot.h2
-rw-r--r--source/Mobs/PassiveAggressiveMonster.cpp4
-rw-r--r--source/Mobs/PassiveAggressiveMonster.h2
-rw-r--r--source/Mobs/PassiveMonster.cpp4
-rw-r--r--source/Mobs/PassiveMonster.h2
-rw-r--r--source/Mobs/Pig.cpp2
-rw-r--r--source/Mobs/Sheep.cpp2
-rw-r--r--source/Mobs/Silverfish.h2
-rw-r--r--source/Mobs/Skeleton.cpp2
-rw-r--r--source/Mobs/Slime.cpp2
-rw-r--r--source/Mobs/SnowGolem.cpp2
-rw-r--r--source/Mobs/Spider.cpp2
-rw-r--r--source/Mobs/Squid.cpp2
-rw-r--r--source/Mobs/Villager.cpp2
-rw-r--r--source/Mobs/Witch.cpp2
-rw-r--r--source/Mobs/Wither.cpp2
-rw-r--r--source/Mobs/Wolf.cpp2
-rw-r--r--source/Mobs/Zombie.cpp2
-rw-r--r--source/Mobs/Zombiepigman.cpp2
-rw-r--r--source/World.cpp39
43 files changed, 320 insertions, 161 deletions
diff --git a/source/Bindings.cpp b/source/Bindings.cpp
index c241bad75..3fa93fce7 100644
--- a/source/Bindings.cpp
+++ b/source/Bindings.cpp
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 10/13/13 18:01:21.
+** Generated automatically by tolua++-1.0.92 on 10/20/13 10:19:10.
*/
#ifndef __cplusplus
@@ -19303,6 +19303,41 @@ static int tolua_AllToLua_cWebAdmin_GetBaseURL00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetHTMLEscapedString of class cWebAdmin */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebAdmin_GetHTMLEscapedString00
+static int tolua_AllToLua_cWebAdmin_GetHTMLEscapedString00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"cWebAdmin",0,&tolua_err) ||
+ !tolua_iscppstring(tolua_S,2,0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,3,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ cWebAdmin* self = (cWebAdmin*) tolua_tousertype(tolua_S,1,0);
+ const AString a_Input = ((const AString) tolua_tocppstring(tolua_S,2,0));
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetHTMLEscapedString'", NULL);
+#endif
+ {
+ AString tolua_ret = (AString) self->GetHTMLEscapedString(a_Input);
+ tolua_pushcppstring(tolua_S,(const char*)tolua_ret);
+ tolua_pushcppstring(tolua_S,(const char*)a_Input);
+ }
+ }
+ return 2;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetHTMLEscapedString'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* method: GetWebTitle of class cWebPlugin */
#ifndef TOLUA_DISABLE_tolua_AllToLua_cWebPlugin_GetWebTitle00
static int tolua_AllToLua_cWebPlugin_GetWebTitle00(lua_State* tolua_S)
@@ -29169,19 +29204,19 @@ static int tolua_AllToLua_cMonster_GetMobType00(lua_State* tolua_S)
#ifndef TOLUA_RELEASE
tolua_Error tolua_err;
if (
- !tolua_isusertype(tolua_S,1,"cMonster",0,&tolua_err) ||
+ !tolua_isusertype(tolua_S,1,"const cMonster",0,&tolua_err) ||
!tolua_isnoobj(tolua_S,2,&tolua_err)
)
goto tolua_lerror;
else
#endif
{
- cMonster* self = (cMonster*) tolua_tousertype(tolua_S,1,0);
+ const cMonster* self = (const cMonster*) tolua_tousertype(tolua_S,1,0);
#ifndef TOLUA_RELEASE
if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetMobType'", NULL);
#endif
{
- int tolua_ret = (int) self->GetMobType();
+ cMonster::eType tolua_ret = (cMonster::eType) self->GetMobType();
tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
}
}
@@ -29194,6 +29229,38 @@ static int tolua_AllToLua_cMonster_GetMobType00(lua_State* tolua_S)
}
#endif //#ifndef TOLUA_DISABLE
+/* method: GetMobFamily of class cMonster */
+#ifndef TOLUA_DISABLE_tolua_AllToLua_cMonster_GetMobFamily00
+static int tolua_AllToLua_cMonster_GetMobFamily00(lua_State* tolua_S)
+{
+#ifndef TOLUA_RELEASE
+ tolua_Error tolua_err;
+ if (
+ !tolua_isusertype(tolua_S,1,"const cMonster",0,&tolua_err) ||
+ !tolua_isnoobj(tolua_S,2,&tolua_err)
+ )
+ goto tolua_lerror;
+ else
+#endif
+ {
+ const cMonster* self = (const cMonster*) tolua_tousertype(tolua_S,1,0);
+#ifndef TOLUA_RELEASE
+ if (!self) tolua_error(tolua_S,"invalid 'self' in function 'GetMobFamily'", NULL);
+#endif
+ {
+ cMonster::eFamily tolua_ret = (cMonster::eFamily) self->GetMobFamily();
+ tolua_pushnumber(tolua_S,(lua_Number)tolua_ret);
+ }
+ }
+ return 1;
+#ifndef TOLUA_RELEASE
+ tolua_lerror:
+ tolua_error(tolua_S,"#ferror in function 'GetMobFamily'.",&tolua_err);
+ return 0;
+#endif
+}
+#endif //#ifndef TOLUA_DISABLE
+
/* Open function */
TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
{
@@ -30826,6 +30893,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_function(tolua_S,"GetPage",tolua_AllToLua_cWebAdmin_GetPage00);
tolua_function(tolua_S,"GetDefaultPage",tolua_AllToLua_cWebAdmin_GetDefaultPage00);
tolua_function(tolua_S,"GetBaseURL",tolua_AllToLua_cWebAdmin_GetBaseURL00);
+ tolua_function(tolua_S,"GetHTMLEscapedString",tolua_AllToLua_cWebAdmin_GetHTMLEscapedString00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cWebPlugin","cWebPlugin","",NULL);
tolua_beginmodule(tolua_S,"cWebPlugin");
@@ -31248,6 +31316,7 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cMonster","cMonster","cPawn",NULL);
tolua_beginmodule(tolua_S,"cMonster");
+ tolua_constant(tolua_S,"mtInvalidType",cMonster::mtInvalidType);
tolua_constant(tolua_S,"mtBat",cMonster::mtBat);
tolua_constant(tolua_S,"mtBlaze",cMonster::mtBlaze);
tolua_constant(tolua_S,"mtCaveSpider",cMonster::mtCaveSpider);
@@ -31277,7 +31346,13 @@ TOLUA_API int tolua_AllToLua_open (lua_State* tolua_S)
tolua_constant(tolua_S,"mtWolf",cMonster::mtWolf);
tolua_constant(tolua_S,"mtZombie",cMonster::mtZombie);
tolua_constant(tolua_S,"mtZombiePigman",cMonster::mtZombiePigman);
+ tolua_constant(tolua_S,"mfHostile",cMonster::mfHostile);
+ tolua_constant(tolua_S,"mfPassive",cMonster::mfPassive);
+ tolua_constant(tolua_S,"mfAmbient",cMonster::mfAmbient);
+ tolua_constant(tolua_S,"mfWater",cMonster::mfWater);
+ tolua_constant(tolua_S,"mfMaxplusone",cMonster::mfMaxplusone);
tolua_function(tolua_S,"GetMobType",tolua_AllToLua_cMonster_GetMobType00);
+ tolua_function(tolua_S,"GetMobFamily",tolua_AllToLua_cMonster_GetMobFamily00);
tolua_endmodule(tolua_S);
tolua_cclass(tolua_S,"cLineBlockTracer","cLineBlockTracer","",NULL);
tolua_beginmodule(tolua_S,"cLineBlockTracer");
diff --git a/source/Bindings.h b/source/Bindings.h
index 1d567520c..0983c7174 100644
--- a/source/Bindings.h
+++ b/source/Bindings.h
@@ -1,6 +1,6 @@
/*
** Lua binding: AllToLua
-** Generated automatically by tolua++-1.0.92 on 10/13/13 18:01:22.
+** Generated automatically by tolua++-1.0.92 on 10/20/13 10:19:10.
*/
/* Exported function */
diff --git a/source/MobSpawner.cpp b/source/MobSpawner.cpp
index 9bff87533..bdeb423c2 100644
--- a/source/MobSpawner.cpp
+++ b/source/MobSpawner.cpp
@@ -47,6 +47,9 @@ cMobSpawner::tMobTypes cMobSpawner::initMobTypesBeforeCx11()
}
+
+
+
cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily,const std::set<cMonster::eType>& a_AllowedTypes) :
m_MonsterFamily(a_MonsterFamily),
m_NewPack(true),
@@ -54,13 +57,17 @@ cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily,const std::set<cMonst
{
for (std::set<cMonster::eType>::const_iterator itr = a_AllowedTypes.begin(); itr != a_AllowedTypes.end(); itr++)
{
- if (cMobTypesManager::getFamilyFromType(*itr) == a_MonsterFamily)
+ if (cMobTypesManager::FamilyFromType(*itr) == a_MonsterFamily)
{
m_AllowedTypes.insert(*itr);
}
}
}
+
+
+
+
bool cMobSpawner::CheckPackCenter(BLOCKTYPE a_BlockType)
{
// Packs of non-water mobs can only be centered on an air block
diff --git a/source/MobTypesManager.cpp b/source/MobTypesManager.cpp
index 600d7992d..aec824a9f 100644
--- a/source/MobTypesManager.cpp
+++ b/source/MobTypesManager.cpp
@@ -8,88 +8,115 @@
#include "FastRandom.h"
-cMobTypesManager::tMobTypes2Names& cMobTypesManager::m_MobsTypes2Names()
+
+
+
+cMobTypesManager::tMobTypes2Names & cMobTypesManager::m_MobsTypes2Names(void)
{
- static std::map<cMonster::eType,std::string>* value = new std::map<cMonster::eType,std::string>(MobTypes2NamesInitializerBeforeCx11());
+ // TODO: This memory leaks
+ static std::map<cMonster::eType, AString> * value = new std::map<cMonster::eType, AString>(MobTypes2NamesInitializerBeforeCx11());
return *value;
}
+
+
+
+
cMobTypesManager::tMobTypes2Names cMobTypesManager::MobTypes2NamesInitializerBeforeCx11()
{
- std::map<cMonster::eType,std::string> toReturn;
- typedef std::map<cMonster::eType,std::string>::value_type ValueType;
- toReturn.insert(ValueType(cMonster::mtMagmaCube,"Magmacube"));
- toReturn.insert(ValueType(cMonster::mtSlime,"Slime"));
- toReturn.insert(ValueType(cMonster::mtBat,"Bat"));
- toReturn.insert(ValueType(cMonster::mtBlaze,"Blaze"));
- toReturn.insert(ValueType(cMonster::mtCaveSpider,"Cavespider"));
- toReturn.insert(ValueType(cMonster::mtChicken,"Chicken"));
- toReturn.insert(ValueType(cMonster::mtCow,"Cow"));
- toReturn.insert(ValueType(cMonster::mtCreeper,"Creeper"));
- toReturn.insert(ValueType(cMonster::mtEnderman,"Enderman"));
- toReturn.insert(ValueType(cMonster::mtGhast,"Ghast"));
- toReturn.insert(ValueType(cMonster::mtMooshroom,"Mooshroom"));
- toReturn.insert(ValueType(cMonster::mtOcelot,"Ocelot"));
- toReturn.insert(ValueType(cMonster::mtPig,"Pig"));
- toReturn.insert(ValueType(cMonster::mtSheep,"Sheep"));
- toReturn.insert(ValueType(cMonster::mtSilverfish,"Silverfish"));
- toReturn.insert(ValueType(cMonster::mtSkeleton,"Skeleton"));
- toReturn.insert(ValueType(cMonster::mtSpider,"Spider"));
- toReturn.insert(ValueType(cMonster::mtSquid,"Squid"));
- toReturn.insert(ValueType(cMonster::mtVillager,"Villager"));
- toReturn.insert(ValueType(cMonster::mtWitch,"Witch"));
- toReturn.insert(ValueType(cMonster::mtWolf,"Wolf"));
- toReturn.insert(ValueType(cMonster::mtZombie,"Zombie"));
- toReturn.insert(ValueType(cMonster::mtZombiePigman,"Zombiepigman"));
+ std::map<cMonster::eType, AString> toReturn;
+ typedef std::map<cMonster::eType, AString>::value_type ValueType;
+ // The strings need to be lowercase (for more efficient comparisons in StringToMobType())
+ toReturn.insert(ValueType(cMonster::mtBat, "bat"));
+ toReturn.insert(ValueType(cMonster::mtBlaze, "blaze"));
+ toReturn.insert(ValueType(cMonster::mtCaveSpider, "cavespider"));
+ toReturn.insert(ValueType(cMonster::mtChicken, "chicken"));
+ toReturn.insert(ValueType(cMonster::mtCow, "cow"));
+ toReturn.insert(ValueType(cMonster::mtCreeper, "creeper"));
+ toReturn.insert(ValueType(cMonster::mtEnderman, "enderman"));
+ toReturn.insert(ValueType(cMonster::mtGhast, "ghast"));
+ toReturn.insert(ValueType(cMonster::mtHorse, "horse"));
+ toReturn.insert(ValueType(cMonster::mtMagmaCube, "magmacube"));
+ toReturn.insert(ValueType(cMonster::mtMooshroom, "mooshroom"));
+ toReturn.insert(ValueType(cMonster::mtOcelot, "ocelot"));
+ toReturn.insert(ValueType(cMonster::mtPig, "pig"));
+ toReturn.insert(ValueType(cMonster::mtSheep, "sheep"));
+ toReturn.insert(ValueType(cMonster::mtSilverfish, "silverfish"));
+ toReturn.insert(ValueType(cMonster::mtSkeleton, "skeleton"));
+ toReturn.insert(ValueType(cMonster::mtSlime, "slime"));
+ toReturn.insert(ValueType(cMonster::mtSpider, "spider"));
+ toReturn.insert(ValueType(cMonster::mtSquid, "squid"));
+ toReturn.insert(ValueType(cMonster::mtVillager, "villager"));
+ toReturn.insert(ValueType(cMonster::mtWitch, "witch"));
+ toReturn.insert(ValueType(cMonster::mtWolf, "wolf"));
+ toReturn.insert(ValueType(cMonster::mtZombie, "zombie"));
+ toReturn.insert(ValueType(cMonster::mtZombiePigman, "zombiepigman"));
return toReturn;
}
-cMobTypesManager::tMobType2Family& cMobTypesManager::m_MobsType2Family()
+
+
+
+
+cMobTypesManager::tMobType2Family & cMobTypesManager::m_MobsType2Family(void)
{
- static std::map<cMonster::eType,cMonster::eFamily>* value = new std::map<cMonster::eType,cMonster::eFamily>(MobType2FamilyInitializerBeforeCx11());
+ // TODO: This memory is leaked:
+ static std::map<cMonster::eType,cMonster::eFamily> * value = new std::map<cMonster::eType,cMonster::eFamily>(MobType2FamilyInitializerBeforeCx11());
return *value;
}
+
+
+
+
cMobTypesManager::tMobType2Family cMobTypesManager::MobType2FamilyInitializerBeforeCx11()
{
std::map<cMonster::eType,cMonster::eFamily> toReturn;
typedef std::map<cMonster::eType,cMonster::eFamily>::value_type ValueType;
- toReturn.insert(ValueType(cMonster::mtBat,cMonster::mfAmbient));
- toReturn.insert(ValueType(cMonster::mtSquid,cMonster::mfWater));
- toReturn.insert(ValueType(cMonster::mtCow,cMonster::mfPassive));
- toReturn.insert(ValueType(cMonster::mtPig,cMonster::mfPassive));
- toReturn.insert(ValueType(cMonster::mtSheep,cMonster::mfPassive));
- toReturn.insert(ValueType(cMonster::mtChicken,cMonster::mfPassive));
- toReturn.insert(ValueType(cMonster::mtVillager,cMonster::mfPassive));
- toReturn.insert(ValueType(cMonster::mtMagmaCube,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtSlime,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtBlaze,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtCaveSpider,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtCreeper,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtEnderman,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtGhast,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtMooshroom,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtOcelot,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtSilverfish,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtSkeleton,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtSpider,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtWitch,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtWolf,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtZombie,cMonster::mfHostile));
- toReturn.insert(ValueType(cMonster::mtZombiePigman,cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtBat, cMonster::mfAmbient));
+ toReturn.insert(ValueType(cMonster::mtBlaze, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtCaveSpider, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtChicken, cMonster::mfPassive));
+ toReturn.insert(ValueType(cMonster::mtCow, cMonster::mfPassive));
+ toReturn.insert(ValueType(cMonster::mtCreeper, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtEnderman, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtGhast, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtHorse, cMonster::mfPassive));
+ toReturn.insert(ValueType(cMonster::mtMagmaCube, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtMooshroom, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtOcelot, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtPig, cMonster::mfPassive));
+ toReturn.insert(ValueType(cMonster::mtSheep, cMonster::mfPassive));
+ toReturn.insert(ValueType(cMonster::mtSilverfish, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtSkeleton, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtSlime, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtSpider, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtSquid, cMonster::mfWater));
+ toReturn.insert(ValueType(cMonster::mtVillager, cMonster::mfPassive));
+ toReturn.insert(ValueType(cMonster::mtWitch, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtWolf, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtZombie, cMonster::mfHostile));
+ toReturn.insert(ValueType(cMonster::mtZombiePigman, cMonster::mfHostile));
return toReturn;
}
-cFastRandom& cMobTypesManager::m_Random()
+
+
+
+cFastRandom & cMobTypesManager::m_Random(void)
{
- static cFastRandom* value = new cFastRandom();
+ // TODO: This memory is leaked:
+ static cFastRandom * value = new cFastRandom();
return *value;
}
-cMonster* cMobTypesManager::NewMonsterFromType(cMonster::eType a_MobType, int a_Size)
+
+
+
+cMonster * cMobTypesManager::NewMonsterFromType(cMonster::eType a_MobType, int a_Size)
{
cMonster * toReturn = NULL;
@@ -98,20 +125,22 @@ cMonster* cMobTypesManager::NewMonsterFromType(cMonster::eType a_MobType, int a_
{
case cMonster::mtMagmaCube:
case cMonster::mtSlime:
+ {
if (a_Size == -1)
{
- a_Size = m_Random().NextInt(2,a_MobType)+1;
+ a_Size = m_Random().NextInt(2, a_MobType) + 1;
}
- if (a_Size <= 0 || a_Size >= 4)
+ if ((a_Size <= 0) || (a_Size >= 4))
{
ASSERT(!"Random for size was supposed to pick in [1..3] and picked outside");
a_Size = 1;
}
break;
- default : break;
- }
+ }
+ default: break;
+ } // switch (a_MobType)
- // the big switch
+ // Create the mob entity
switch (a_MobType)
{
case cMonster::mtMagmaCube: toReturn = new cMagmaCube(a_Size); break;
@@ -124,13 +153,15 @@ cMonster* cMobTypesManager::NewMonsterFromType(cMonster::eType a_MobType, int a_
case cMonster::mtCreeper: toReturn = new cCreeper(); break;
case cMonster::mtEnderman: toReturn = new cEnderman(); break;
case cMonster::mtGhast: toReturn = new cGhast(); break;
+ // TODO:
+ // case cMonster::mtHorse: toReturn = new cHorse(); break;
case cMonster::mtMooshroom: toReturn = new cMooshroom(); break;
case cMonster::mtOcelot: toReturn = new cOcelot(); break;
case cMonster::mtPig: toReturn = new cPig(); break;
// TODO: Implement sheep color
case cMonster::mtSheep: toReturn = new cSheep(0); break;
case cMonster::mtSilverfish: toReturn = new cSilverfish(); break;
- // TODO: Implement wither geration
+ // TODO: Implement wither skeleton geration
case cMonster::mtSkeleton: toReturn = new cSkeleton(false); break;
case cMonster::mtSpider: toReturn = new cSpider(); break;
case cMonster::mtSquid: toReturn = new cSquid(); break;
@@ -148,21 +179,28 @@ cMonster* cMobTypesManager::NewMonsterFromType(cMonster::eType a_MobType, int a_
}
-const std::string& cMobTypesManager::fromMobTypeToString(cMonster::eType a_MobType)
+
+
+
+AString cMobTypesManager::MobTypeToString(cMonster::eType a_MobType)
{
- static std::string toReturnDefault = "";
- std::string& toReturn = toReturnDefault;
- std::map<cMonster::eType,std::string>::const_iterator itr = m_MobsTypes2Names().find(a_MobType);
+ std::map<cMonster::eType, AString>::const_iterator itr = m_MobsTypes2Names().find(a_MobType);
if (itr != m_MobsTypes2Names().end())
{
- toReturn = itr->second;
+ return itr->second;
}
- return toReturn;
+ return "";
}
-cMonster::eType cMobTypesManager::fromStringToMobType(const std::string& a_Name)
+
+
+
+
+cMonster::eType cMobTypesManager::StringToMobType(const AString & a_Name)
{
- for(std::map<cMonster::eType,std::string>::const_iterator itr = m_MobsTypes2Names().begin(); itr != m_MobsTypes2Names().end(); itr++)
+ AString lcName(a_Name);
+ StrToLower(lcName);
+ for (std::map<cMonster::eType, AString>::const_iterator itr = m_MobsTypes2Names().begin(); itr != m_MobsTypes2Names().end(); itr++)
{
if (itr->second == a_Name)
{
@@ -172,13 +210,21 @@ cMonster::eType cMobTypesManager::fromStringToMobType(const std::string& a_Name)
return cMonster::mtInvalidType;
}
-cMonster::eFamily cMobTypesManager::getFamilyFromType(cMonster::eType a_Type)
+
+
+
+
+cMonster::eFamily cMobTypesManager::FamilyFromType(cMonster::eType a_Type)
{
cMonster::eFamily toReturn = cMonster::mfMaxplusone;
- std::map<cMonster::eType,cMonster::eFamily>::const_iterator itr = m_MobsType2Family().find(a_Type);
+ std::map<cMonster::eType, cMonster::eFamily>::const_iterator itr = m_MobsType2Family().find(a_Type);
if (itr != m_MobsType2Family().end())
{
toReturn = itr->second;
}
return toReturn;
}
+
+
+
+
diff --git a/source/MobTypesManager.h b/source/MobTypesManager.h
index 941dac729..6fc8bcfeb 100644
--- a/source/MobTypesManager.h
+++ b/source/MobTypesManager.h
@@ -1,44 +1,54 @@
#pragma once
-#include <vector>
#include "Mobs/Monster.h" // this is a side effect of declaring cMonster::eType inside cMonster MG TODO : make a namespace
+
+
+
+// fwd:
class cFastRandom;
-// this aggregate static functionnalities about mob types (some could call it helper)
-// functionnalities are (in the first version) :
-// - create a mob from its type (as enum) (in that way it is a compiler-proxy for mobs)
-// - can transform MobTypes from enums to string and reciprocal
-// - return mob family from providen type
+
+
+
+
+/**
+This class aggregates static functions about mob types:
+ - create a mob from its type (as enum) (in that way it is a compiler-proxy for mobs)
+ - transform MobTypes from enums to string and vice versa
+ - return mob family from given type
+*/
class cMobTypesManager
{
public:
- static const std::string& fromMobTypeToString(cMonster::eType a_MobType);
- static cMonster::eType fromStringToMobType(const std::string& a_MobTypeName);
- static cMonster::eFamily getFamilyFromType(cMonster::eType a_MobType);
+ static AString MobTypeToString(cMonster::eType a_MobType);
+ static cMonster::eType StringToMobType(const AString& a_MobTypeName);
+ static cMonster::eFamily FamilyFromType(cMonster::eType a_MobType);
+
+ /** create a new object of the specified mob.
+ a_MobType is the type of the mob to be created
+ a_Size is the size (for mobs with size)
+ if a_Size is let to -1 for entities that need size, size will be random
+ asserts and returns null if mob type is not specified
+ asserts if invalid size for mobs that need size
+ */
+ static cMonster * NewMonsterFromType(cMonster::eType a_MobType, int a_Size = -1);
protected :
typedef const std::map<cMonster::eType,std::string> tMobTypes2Names;
- static tMobTypes2Names& m_MobsTypes2Names();
- static tMobTypes2Names MobTypes2NamesInitializerBeforeCx11();
+ static tMobTypes2Names& m_MobsTypes2Names(void);
+ static tMobTypes2Names MobTypes2NamesInitializerBeforeCx11(void);
typedef const std::map<cMonster::eType,cMonster::eFamily> tMobType2Family;
- static tMobType2Family& m_MobsType2Family();
- static tMobType2Family MobType2FamilyInitializerBeforeCx11();
+ static tMobType2Family& m_MobsType2Family(void);
+ static tMobType2Family MobType2FamilyInitializerBeforeCx11(void);
- static cFastRandom& m_Random();
+ static cFastRandom & m_Random(void);
public :
- /** create a new object of the specified mob.
- Warning, new without delete here;
- a_MobType is the type of the mob to be created
- a_Size is the size (for mobs with size)
- if a_Size is let to -1 for entities that need size, size will be random
- assert or return null if mob type is not specified
- assert if size < 1 or > 3 for entities that need size
- */
- static cMonster* NewMonsterFromType(cMonster::eType a_MobType, int a_Size=-1);
+} ;
+
+
-}; // tolua_export
diff --git a/source/Mobs/AggressiveMonster.cpp b/source/Mobs/AggressiveMonster.cpp
index 93dba6d7b..ee6252656 100644
--- a/source/Mobs/AggressiveMonster.cpp
+++ b/source/Mobs/AggressiveMonster.cpp
@@ -12,8 +12,8 @@
-cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
- super(a_ConfigName, a_ProtocolMobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height),
+cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
+ super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height),
m_ChaseTime(999999)
{
m_EMPersonality = AGGRESSIVE;
diff --git a/source/Mobs/AggressiveMonster.h b/source/Mobs/AggressiveMonster.h
index f22ed5b89..5a0d93f3d 100644
--- a/source/Mobs/AggressiveMonster.h
+++ b/source/Mobs/AggressiveMonster.h
@@ -13,7 +13,7 @@ class cAggressiveMonster :
typedef cMonster super;
public:
- cAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual void Tick (float a_Dt, cChunk & a_Chunk) override;
virtual void InStateChasing(float a_Dt) override;
diff --git a/source/Mobs/Bat.cpp b/source/Mobs/Bat.cpp
index 715f25483..b9c82996b 100644
--- a/source/Mobs/Bat.cpp
+++ b/source/Mobs/Bat.cpp
@@ -8,7 +8,7 @@
cBat::cBat(void) :
// TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Bat", 65, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7)
+ super("Bat", mtBat, "mob.bat.hurt", "mob.bat.death", 0.7, 0.7)
{
}
diff --git a/source/Mobs/Blaze.cpp b/source/Mobs/Blaze.cpp
index dbbccf417..74c82c081 100644
--- a/source/Mobs/Blaze.cpp
+++ b/source/Mobs/Blaze.cpp
@@ -9,7 +9,7 @@
cBlaze::cBlaze(void) :
// TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Blaze", 61, "mob.blaze.hit", "mob.blaze.death", 0.7, 1.8)
+ super("Blaze", mtBlaze, "mob.blaze.hit", "mob.blaze.death", 0.7, 1.8)
{
}
diff --git a/source/Mobs/Cavespider.cpp b/source/Mobs/Cavespider.cpp
index 2d50b391a..aba1ff9f5 100644
--- a/source/Mobs/Cavespider.cpp
+++ b/source/Mobs/Cavespider.cpp
@@ -9,7 +9,7 @@
cCavespider::cCavespider(void) :
- super("Cavespider", 59, "mob.spider.say", "mob.spider.death", 0.7, 0.5)
+ super("Cavespider", mtCaveSpider, "mob.spider.say", "mob.spider.death", 0.7, 0.5)
{
}
diff --git a/source/Mobs/Chicken.cpp b/source/Mobs/Chicken.cpp
index 3da9781d3..434a32f94 100644
--- a/source/Mobs/Chicken.cpp
+++ b/source/Mobs/Chicken.cpp
@@ -14,7 +14,7 @@
cChicken::cChicken(void) :
- super("Chicken", 93, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4)
+ super("Chicken", mtChicken, "mob.chicken.hurt", "mob.chicken.hurt", 0.3, 0.4)
{
}
diff --git a/source/Mobs/Cow.cpp b/source/Mobs/Cow.cpp
index dc59016e7..9eb74dac2 100644
--- a/source/Mobs/Cow.cpp
+++ b/source/Mobs/Cow.cpp
@@ -11,7 +11,7 @@
cCow::cCow(void) :
- super("Cow", 92, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
+ super("Cow", mtCow, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
{
}
diff --git a/source/Mobs/Creeper.cpp b/source/Mobs/Creeper.cpp
index b41b05f42..4e11ae13e 100644
--- a/source/Mobs/Creeper.cpp
+++ b/source/Mobs/Creeper.cpp
@@ -9,7 +9,7 @@
cCreeper::cCreeper(void) :
- super("Creeper", 50, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8),
+ super("Creeper", mtCreeper, "mob.creeper.say", "mob.creeper.say", 0.6, 1.8),
m_bIsBlowing(false),
m_bIsCharged(false)
{
diff --git a/source/Mobs/EnderDragon.cpp b/source/Mobs/EnderDragon.cpp
index 64f2bedfa..acd81cde1 100644
--- a/source/Mobs/EnderDragon.cpp
+++ b/source/Mobs/EnderDragon.cpp
@@ -9,7 +9,7 @@
cEnderDragon::cEnderDragon(void) :
// TODO: Vanilla source says this, but is it right? Dragons fly, they don't stand
- super("EnderDragon", 63, "mob.enderdragon.hit", "mob.enderdragon.end", 16.0, 8.0)
+ super("EnderDragon", mtEnderDragon, "mob.enderdragon.hit", "mob.enderdragon.end", 16.0, 8.0)
{
}
diff --git a/source/Mobs/Enderman.cpp b/source/Mobs/Enderman.cpp
index c0ea3d6aa..a784131e4 100644
--- a/source/Mobs/Enderman.cpp
+++ b/source/Mobs/Enderman.cpp
@@ -8,7 +8,7 @@
cEnderman::cEnderman(void) :
- super("Enderman", 58, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.9),
+ super("Enderman", mtEnderman, "mob.endermen.hit", "mob.endermen.death", 0.5, 2.9),
m_bIsScreaming(false),
CarriedBlock(E_BLOCK_AIR),
CarriedMeta(0)
diff --git a/source/Mobs/Ghast.cpp b/source/Mobs/Ghast.cpp
index 288d0c28a..419c8474d 100644
--- a/source/Mobs/Ghast.cpp
+++ b/source/Mobs/Ghast.cpp
@@ -8,7 +8,7 @@
cGhast::cGhast(void) :
- super("Ghast", 56, "mob.ghast.scream", "mob.ghast.death", 4, 4)
+ super("Ghast", mtGhast, "mob.ghast.scream", "mob.ghast.death", 4, 4)
{
}
diff --git a/source/Mobs/Giant.cpp b/source/Mobs/Giant.cpp
index a02758a43..f41977535 100644
--- a/source/Mobs/Giant.cpp
+++ b/source/Mobs/Giant.cpp
@@ -9,7 +9,7 @@
cGiant::cGiant(void) :
// TODO: The size is only a guesstimate, measure in vanilla and fix the size values here
- super("Giant", 53, "mob.zombie.hurt", "mob.zombie.death", 2.0, 13.5)
+ super("Giant", mtGiant, "mob.zombie.hurt", "mob.zombie.death", 2.0, 13.5)
{
}
diff --git a/source/Mobs/Horse.cpp b/source/Mobs/Horse.cpp
index 1f791d236..f9705a451 100644
--- a/source/Mobs/Horse.cpp
+++ b/source/Mobs/Horse.cpp
@@ -10,7 +10,7 @@
cHorse::cHorse(int Type, int Color, int Style, int TameTimes) :
- super("Horse", 100, "mob.horse.hit", "mob.horse.death", 1.4, 1.6),
+ super("Horse", mtHorse, "mob.horse.hit", "mob.horse.death", 1.4, 1.6),
m_bHasChest(false),
m_bIsEating(false),
m_bIsRearing(false),
diff --git a/source/Mobs/IronGolem.cpp b/source/Mobs/IronGolem.cpp
index 42d312c23..47c961098 100644
--- a/source/Mobs/IronGolem.cpp
+++ b/source/Mobs/IronGolem.cpp
@@ -8,7 +8,7 @@
cIronGolem::cIronGolem(void) :
- super("IronGolem", 99, "mob.IronGolem.hit", "mob.IronGolem.death", 1.4, 2.9)
+ super("IronGolem", mtIronGolem, "mob.IronGolem.hit", "mob.IronGolem.death", 1.4, 2.9)
{
}
diff --git a/source/Mobs/Magmacube.cpp b/source/Mobs/Magmacube.cpp
index c72b4831b..86447ff6b 100644
--- a/source/Mobs/Magmacube.cpp
+++ b/source/Mobs/Magmacube.cpp
@@ -8,7 +8,7 @@
cMagmaCube::cMagmaCube(int a_Size) :
- super("MagmaCube", 62, "mob.MagmaCube.big", "mob.MagmaCube.big", 0.6 * a_Size, 0.6 * a_Size),
+ super("MagmaCube", mtMagmaCube, "mob.MagmaCube.big", "mob.MagmaCube.big", 0.6 * a_Size, 0.6 * a_Size),
m_Size(a_Size)
{
}
diff --git a/source/Mobs/Monster.cpp b/source/Mobs/Monster.cpp
index 51ea644d3..591c41e22 100644
--- a/source/Mobs/Monster.cpp
+++ b/source/Mobs/Monster.cpp
@@ -25,7 +25,7 @@
-cMonster::cMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
+cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
: super(etMonster, a_Width, a_Height)
, m_Target(NULL)
, m_AttackRate(3)
@@ -34,7 +34,7 @@ cMonster::cMonster(const AString & a_ConfigName, char a_ProtocolMobType, const A
, m_DestinationTime( 0 )
, m_DestroyTimer( 0 )
, m_Jump(0)
- , m_MobType(a_ProtocolMobType)
+ , m_MobType(a_MobType)
, m_SoundHurt(a_SoundHurt)
, m_SoundDeath(a_SoundDeath)
, m_EMState(IDLE)
@@ -514,5 +514,9 @@ void cMonster::HandleDaylightBurning(cChunk & a_Chunk)
cMonster::eFamily cMonster::GetMobFamily(void) const
{
- return cMobTypesManager::getFamilyFromType(GetMobTypeAsEnum());
+ return cMobTypesManager::FamilyFromType(m_MobType);
}
+
+
+
+
diff --git a/source/Mobs/Monster.h b/source/Mobs/Monster.h
index be60d9e00..c416d026c 100644
--- a/source/Mobs/Monster.h
+++ b/source/Mobs/Monster.h
@@ -26,6 +26,8 @@ public:
/// This identifies individual monster type, as well as their network type-ID
enum eType
{
+ mtInvalidType = -1,
+
mtBat = E_META_SPAWN_EGG_BAT,
mtBlaze = E_META_SPAWN_EGG_BLAZE,
mtCaveSpider = E_META_SPAWN_EGG_CAVE_SPIDER,
@@ -55,7 +57,6 @@ public:
mtWolf = E_META_SPAWN_EGG_WOLF,
mtZombie = E_META_SPAWN_EGG_ZOMBIE,
mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
- mtInvalidType
} ;
enum eFamily
@@ -74,10 +75,10 @@ public:
/** Creates the mob object.
* If a_ConfigName is not empty, the configuration is loaded using GetMonsterConfig()
- * a_ProtocolMobType is the ID of the mob used in the protocol ( http://wiki.vg/Entities#Mobs , 2012_12_22)
+ * a_MobType is the type of the mob (also used in the protocol ( http://wiki.vg/Entities#Mobs , 2012_12_22))
* a_SoundHurt and a_SoundDeath are assigned into m_SoundHurt and m_SoundDeath, respectively
*/
- cMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
CLASS_PROTODEF(cMonster);
@@ -92,9 +93,10 @@ public:
virtual void MoveToPosition(const Vector3f & a_Position);
virtual bool ReachedDestination(void);
- char GetMobType(void) const {return m_MobType; } // MG TODO : see if we can delete this one.
- eType GetMobTypeAsEnum(void) const {return (eType)m_MobType; } // MG TODO : see if we should store m_MobType as enum instead of char.
+ // tolua_begin
+ eType GetMobType(void) const {return m_MobType; }
eFamily GetMobFamily(void) const;
+ // tolua_end
const char * GetState();
@@ -116,8 +118,6 @@ public:
virtual void Attack(float a_Dt);
- int GetMobType() { return m_MobType; } // tolua_export
-
int GetAttackRate(){return (int)m_AttackRate;}
void SetAttackRate(int ar);
void SetAttackRange(float ar);
@@ -150,7 +150,7 @@ protected:
float m_DestroyTimer;
float m_Jump;
- char m_MobType;
+ eType m_MobType;
AString m_SoundHurt;
AString m_SoundDeath;
diff --git a/source/Mobs/Mooshroom.cpp b/source/Mobs/Mooshroom.cpp
index 5d2c901ba..940e2db44 100644
--- a/source/Mobs/Mooshroom.cpp
+++ b/source/Mobs/Mooshroom.cpp
@@ -14,7 +14,7 @@
cMooshroom::cMooshroom(void) :
- super("Mooshroom", 96, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
+ super("Mooshroom", mtMooshroom, "mob.cow.hurt", "mob.cow.hurt", 0.9, 1.3)
{
}
diff --git a/source/Mobs/Ocelot.h b/source/Mobs/Ocelot.h
index 6d24c5672..adb7a1f75 100644
--- a/source/Mobs/Ocelot.h
+++ b/source/Mobs/Ocelot.h
@@ -14,7 +14,7 @@ class cOcelot :
public:
cOcelot(void) :
- super("Ocelot", 98, "mob.cat.hitt", "mob.cat.hitt", 0.6, 0.8)
+ super("Ocelot", mtOcelot, "mob.cat.hitt", "mob.cat.hitt", 0.6, 0.8)
{
}
diff --git a/source/Mobs/PassiveAggressiveMonster.cpp b/source/Mobs/PassiveAggressiveMonster.cpp
index e473137a9..28de65905 100644
--- a/source/Mobs/PassiveAggressiveMonster.cpp
+++ b/source/Mobs/PassiveAggressiveMonster.cpp
@@ -9,8 +9,8 @@
-cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
- super(a_ConfigName, a_ProtocolMobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
+cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
+ super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
{
m_EMPersonality = PASSIVE;
}
diff --git a/source/Mobs/PassiveAggressiveMonster.h b/source/Mobs/PassiveAggressiveMonster.h
index 243dfff38..2c5ef30b1 100644
--- a/source/Mobs/PassiveAggressiveMonster.h
+++ b/source/Mobs/PassiveAggressiveMonster.h
@@ -13,7 +13,7 @@ class cPassiveAggressiveMonster :
typedef cAggressiveMonster super;
public:
- cPassiveAggressiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual void DoTakeDamage(TakeDamageInfo & a_TDI) override;
} ;
diff --git a/source/Mobs/PassiveMonster.cpp b/source/Mobs/PassiveMonster.cpp
index 8c69c8059..91ceb5a53 100644
--- a/source/Mobs/PassiveMonster.cpp
+++ b/source/Mobs/PassiveMonster.cpp
@@ -9,8 +9,8 @@
-cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
- super(a_ConfigName, a_ProtocolMobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
+cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
+ super(a_ConfigName, a_MobType, a_SoundHurt, a_SoundDeath, a_Width, a_Height)
{
m_EMPersonality = PASSIVE;
}
diff --git a/source/Mobs/PassiveMonster.h b/source/Mobs/PassiveMonster.h
index 908bb0ce6..14a6be6b1 100644
--- a/source/Mobs/PassiveMonster.h
+++ b/source/Mobs/PassiveMonster.h
@@ -13,7 +13,7 @@ class cPassiveMonster :
typedef cMonster super;
public:
- cPassiveMonster(const AString & a_ConfigName, char a_ProtocolMobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
+ cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual void Tick(float a_Dt, cChunk & a_Chunk) override;
diff --git a/source/Mobs/Pig.cpp b/source/Mobs/Pig.cpp
index cd18c087f..5427cf35f 100644
--- a/source/Mobs/Pig.cpp
+++ b/source/Mobs/Pig.cpp
@@ -10,7 +10,7 @@
cPig::cPig(void) :
- super("Pig", 90, "mob.pig.say", "mob.pig.death", 0.9, 0.9),
+ super("Pig", mtPig, "mob.pig.say", "mob.pig.death", 0.9, 0.9),
m_bIsSaddled(false)
{
}
diff --git a/source/Mobs/Sheep.cpp b/source/Mobs/Sheep.cpp
index 440c5c2b9..0d7d43e27 100644
--- a/source/Mobs/Sheep.cpp
+++ b/source/Mobs/Sheep.cpp
@@ -11,7 +11,7 @@
cSheep::cSheep(int a_Color) :
- super("Sheep", 91, "mob.sheep.say", "mob.sheep.say", 0.6, 1.3),
+ super("Sheep", mtSheep, "mob.sheep.say", "mob.sheep.say", 0.6, 1.3),
m_IsSheared(false),
m_WoolColor(a_Color)
{
diff --git a/source/Mobs/Silverfish.h b/source/Mobs/Silverfish.h
index d632ac169..a6e11c49d 100644
--- a/source/Mobs/Silverfish.h
+++ b/source/Mobs/Silverfish.h
@@ -14,7 +14,7 @@ class cSilverfish :
public:
cSilverfish(void) :
- super("Silverfish", 60, "mob.silverfish.hit", "mob.silverfish.kill", 0.3, 0.7)
+ super("Silverfish", mtSilverfish, "mob.silverfish.hit", "mob.silverfish.kill", 0.3, 0.7)
{
}
diff --git a/source/Mobs/Skeleton.cpp b/source/Mobs/Skeleton.cpp
index 6297b867c..37a724848 100644
--- a/source/Mobs/Skeleton.cpp
+++ b/source/Mobs/Skeleton.cpp
@@ -9,7 +9,7 @@
cSkeleton::cSkeleton(bool IsWither) :
- super("Skeleton", 51, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8),
+ super("Skeleton", mtSkeleton, "mob.skeleton.hurt", "mob.skeleton.death", 0.6, 1.8),
m_bIsWither(IsWither)
{
SetBurnsInDaylight(true);
diff --git a/source/Mobs/Slime.cpp b/source/Mobs/Slime.cpp
index 7a9487a06..19f376c21 100644
--- a/source/Mobs/Slime.cpp
+++ b/source/Mobs/Slime.cpp
@@ -9,7 +9,7 @@
/// Creates a slime of the specified size; size is 1 .. 3, with 1 being the smallest
cSlime::cSlime(int a_Size) :
- super("Slime", 55, "mob.slime.attack", "mob.slime.attack", 0.6 * a_Size, 0.6 * a_Size),
+ super("Slime", mtSlime, "mob.slime.attack", "mob.slime.attack", 0.6 * a_Size, 0.6 * a_Size),
m_Size(a_Size)
{
}
diff --git a/source/Mobs/SnowGolem.cpp b/source/Mobs/SnowGolem.cpp
index 51125542d..9e199f87e 100644
--- a/source/Mobs/SnowGolem.cpp
+++ b/source/Mobs/SnowGolem.cpp
@@ -8,7 +8,7 @@
cSnowGolem::cSnowGolem(void) :
- super("SnowGolem", 97, "", "", 0.4, 1.8)
+ super("SnowGolem", mtSnowGolem, "", "", 0.4, 1.8)
{
}
diff --git a/source/Mobs/Spider.cpp b/source/Mobs/Spider.cpp
index 2f244cdbc..b19a5dcef 100644
--- a/source/Mobs/Spider.cpp
+++ b/source/Mobs/Spider.cpp
@@ -8,7 +8,7 @@
cSpider::cSpider(void) :
- super("Spider", 52, "mob.spider.say", "mob.spider.death", 1.4, 0.9)
+ super("Spider", mtSpider, "mob.spider.say", "mob.spider.death", 1.4, 0.9)
{
}
diff --git a/source/Mobs/Squid.cpp b/source/Mobs/Squid.cpp
index e6a44079a..a311108ae 100644
--- a/source/Mobs/Squid.cpp
+++ b/source/Mobs/Squid.cpp
@@ -10,7 +10,7 @@
cSquid::cSquid(void) :
- super("Squid", 94, "", "", 0.95, 0.95)
+ super("Squid", mtSquid, "", "", 0.95, 0.95)
{
}
diff --git a/source/Mobs/Villager.cpp b/source/Mobs/Villager.cpp
index 97d6dc3ca..7f89fb6cc 100644
--- a/source/Mobs/Villager.cpp
+++ b/source/Mobs/Villager.cpp
@@ -9,7 +9,7 @@
cVillager::cVillager(eVillagerType VillagerType) :
- super("Villager", 120, "", "", 0.6, 1.8),
+ super("Villager", mtVillager, "", "", 0.6, 1.8),
m_Type(VillagerType)
{
}
diff --git a/source/Mobs/Witch.cpp b/source/Mobs/Witch.cpp
index b29783853..25d27041f 100644
--- a/source/Mobs/Witch.cpp
+++ b/source/Mobs/Witch.cpp
@@ -8,7 +8,7 @@
cWitch::cWitch(void) :
- super("Witch", 66, "", "", 0.6, 1.8)
+ super("Witch", mtWitch, "", "", 0.6, 1.8)
{
}
diff --git a/source/Mobs/Wither.cpp b/source/Mobs/Wither.cpp
index 8b77284c8..c46e0beab 100644
--- a/source/Mobs/Wither.cpp
+++ b/source/Mobs/Wither.cpp
@@ -8,7 +8,7 @@
cWither::cWither(void) :
- super("Wither", 64, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0)
+ super("Wither", mtWither, "mob.wither.hurt", "mob.wither.death", 0.9, 4.0)
{
}
diff --git a/source/Mobs/Wolf.cpp b/source/Mobs/Wolf.cpp
index e76f991dc..2baeb4b7b 100644
--- a/source/Mobs/Wolf.cpp
+++ b/source/Mobs/Wolf.cpp
@@ -10,7 +10,7 @@
cWolf::cWolf(void) :
- super("Wolf", 95, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8),
+ super("Wolf", mtWolf, "mob.wolf.hurt", "mob.wolf.death", 0.6, 0.8),
m_bIsAngry(false),
m_bIsTame(false),
m_bIsSitting(false),
diff --git a/source/Mobs/Zombie.cpp b/source/Mobs/Zombie.cpp
index f495fe5ee..1752ec390 100644
--- a/source/Mobs/Zombie.cpp
+++ b/source/Mobs/Zombie.cpp
@@ -9,7 +9,7 @@
cZombie::cZombie(bool IsVillagerZombie) :
- super("Zombie", 54, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8),
+ super("Zombie", mtZombie, "mob.zombie.hurt", "mob.zombie.death", 0.6, 1.8),
m_bIsConverting(false),
m_bIsVillagerZombie(IsVillagerZombie)
{
diff --git a/source/Mobs/Zombiepigman.cpp b/source/Mobs/Zombiepigman.cpp
index 1e31a72d9..6ac89ed4c 100644
--- a/source/Mobs/Zombiepigman.cpp
+++ b/source/Mobs/Zombiepigman.cpp
@@ -9,7 +9,7 @@
cZombiePigman::cZombiePigman(void) :
- super("ZombiePigman", 57, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8)
+ super("ZombiePigman", mtZombiePigman, "mob.zombiepig.zpighurt", "mob.zombiepig.zpigdeath", 0.6, 1.8)
{
}
diff --git a/source/World.cpp b/source/World.cpp
index 039e192d9..bcf32df85 100644
--- a/source/World.cpp
+++ b/source/World.cpp
@@ -489,19 +489,36 @@ void cWorld::Start(void)
m_GameMode = (eGameMode)IniFile.GetValueSetI("GameMode", "GameMode", m_GameMode);
+ // Load allowed mobs:
+ const char * DefaultMonsters = "";
+ switch (m_Dimension)
+ {
+ case dimOverworld: DefaultMonsters = "bat, cavespider, chicken, cow, creeper, enderman, horse, mooshroom, ocelot, pig, sheep, silverfish, skeleton, slime, spider, squid, wolf, zombie"; break;
+ case dimNether: DefaultMonsters = "blaze, ghast, magmacube, skeleton, zombie, zombiepigman"; break;
+ case dimEnd: DefaultMonsters = "enderman"; break;
+ default:
+ {
+ ASSERT(!"Unhandled world dimension");
+ DefaultMonsters = "wither";
+ break;
+ }
+ }
m_bAnimals = IniFile.GetValueB("Monsters", "AnimalsOn", true);
- AString sAllMonsters = IniFile.GetValue("Monsters", "Types");
- AStringVector SplitList = StringSplit(sAllMonsters, ",");
- for (unsigned int i = 0; i < SplitList.size(); ++i)
+ AString AllMonsters = IniFile.GetValueSet("Monsters", "Types", DefaultMonsters);
+ AStringVector SplitList = StringSplitAndTrim(AllMonsters, ",");
+ for (AStringVector::const_iterator itr = SplitList.begin(), end = SplitList.end(); itr != end; ++itr)
{
- cMonster::eType ToAdd = cMobTypesManager::fromStringToMobType(SplitList[i]);
+ cMonster::eType ToAdd = cMobTypesManager::StringToMobType(*itr);
if (ToAdd != cMonster::mtInvalidType)
{
m_AllowedMobs.insert(ToAdd);
- LOGD("Allowed mob: %s",cMobTypesManager::fromMobTypeToString(ToAdd).c_str()); // a bit reverse working, but very few ressources wasted
+ LOGD("Allowed mob: %s", cMobTypesManager::MobTypeToString(ToAdd).c_str()); // a bit reverse working, but very few ressources wasted
}
- };
-
+ else
+ {
+ LOG("World \"%s\": Unknown mob type: %s", m_WorldName.c_str(), itr->c_str());
+ }
+ }
m_ChunkMap = new cChunkMap(this);
@@ -532,10 +549,10 @@ void cWorld::Start(void)
m_TickThread.Start();
// Init of the spawn monster time (as they are supposed to have different spawn rate)
- m_LastSpawnMonster.insert(std::map<cMonster::eFamily,Int64>::value_type(cMonster::mfHostile,0));
- m_LastSpawnMonster.insert(std::map<cMonster::eFamily,Int64>::value_type(cMonster::mfPassive,0));
- m_LastSpawnMonster.insert(std::map<cMonster::eFamily,Int64>::value_type(cMonster::mfAmbient,0));
- m_LastSpawnMonster.insert(std::map<cMonster::eFamily,Int64>::value_type(cMonster::mfWater,0));
+ m_LastSpawnMonster.insert(std::map<cMonster::eFamily, Int64>::value_type(cMonster::mfHostile, 0));
+ m_LastSpawnMonster.insert(std::map<cMonster::eFamily, Int64>::value_type(cMonster::mfPassive, 0));
+ m_LastSpawnMonster.insert(std::map<cMonster::eFamily, Int64>::value_type(cMonster::mfAmbient, 0));
+ m_LastSpawnMonster.insert(std::map<cMonster::eFamily, Int64>::value_type(cMonster::mfWater, 0));
// Save any changes that the defaults may have done to the ini file: