1
0

Added first test to show the object can be created

This commit is contained in:
Tycho 2014-09-17 18:40:10 +01:00
parent 26a4845a99
commit 6e7c0e33b5
46 changed files with 683 additions and 458 deletions

View File

@ -129,6 +129,8 @@ set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPER
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.h PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/LuaState_Call.inc PROPERTIES GENERATED TRUE)
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/Bindings/Bindings.cpp PROPERTIES COMPILE_FLAGS -Wno-error)
if(NOT MSVC)
add_library(Bindings ${SRCS} ${HDRS})

View File

@ -109,7 +109,7 @@ void cDispenserEntity::DropSpenseFromSlot(cChunk & a_Chunk, int a_SlotNum)
{
double MobX = 0.5 + (DispX + DispChunk->GetPosX() * cChunkDef::Width);
double MobZ = 0.5 + (DispZ + DispChunk->GetPosZ() * cChunkDef::Width);
if (m_World->SpawnMob(MobX, DispY, MobZ, (cMonster::eType)m_Contents.GetSlot(a_SlotNum).m_ItemDamage) >= 0)
if (m_World->SpawnMob(MobX, DispY, MobZ, (eMonsterType)m_Contents.GetSlot(a_SlotNum).m_ItemDamage) >= 0)
{
m_Contents.ChangeSlotCount(a_SlotNum, -1);
}

View File

@ -261,34 +261,34 @@ int StringToMobType(const AString & a_MobString)
const char * m_String;
} MobMap [] =
{
{cMonster::mtCreeper, "Creeper"},
{cMonster::mtSkeleton, "Skeleton"},
{cMonster::mtSpider, "Spider"},
{cMonster::mtGiant, "Giant"},
{cMonster::mtZombie, "Zombie"},
{cMonster::mtSlime, "Slime"},
{cMonster::mtGhast, "Ghast"},
{cMonster::mtZombiePigman, "ZombiePigman"},
{cMonster::mtEnderman, "Enderman"},
{cMonster::mtCaveSpider, "CaveSpider"},
{cMonster::mtSilverfish, "SilverFish"},
{cMonster::mtBlaze, "Blaze"},
{cMonster::mtMagmaCube, "MagmaCube"},
{cMonster::mtEnderDragon, "EnderDragon"},
{cMonster::mtWither, "Wither"},
{cMonster::mtBat, "Bat"},
{cMonster::mtWitch, "Witch"},
{cMonster::mtPig, "Pig"},
{cMonster::mtSheep, "Sheep"},
{cMonster::mtCow, "Cow"},
{cMonster::mtChicken, "Chicken"},
{cMonster::mtSquid, "Squid"},
{cMonster::mtWolf, "Wolf"},
{cMonster::mtMooshroom, "Mooshroom"},
{cMonster::mtSnowGolem, "SnowGolem"},
{cMonster::mtOcelot, "Ocelot"},
{cMonster::mtIronGolem, "IronGolem"},
{cMonster::mtVillager, "Villager"},
{mtCreeper, "Creeper"},
{mtSkeleton, "Skeleton"},
{mtSpider, "Spider"},
{mtGiant, "Giant"},
{mtZombie, "Zombie"},
{mtSlime, "Slime"},
{mtGhast, "Ghast"},
{mtZombiePigman, "ZombiePigman"},
{mtEnderman, "Enderman"},
{mtCaveSpider, "CaveSpider"},
{mtSilverfish, "SilverFish"},
{mtBlaze, "Blaze"},
{mtMagmaCube, "MagmaCube"},
{mtEnderDragon, "EnderDragon"},
{mtWither, "Wither"},
{mtBat, "Bat"},
{mtWitch, "Witch"},
{mtPig, "Pig"},
{mtSheep, "Sheep"},
{mtCow, "Cow"},
{mtChicken, "Chicken"},
{mtSquid, "Squid"},
{mtWolf, "Wolf"},
{mtMooshroom, "Mooshroom"},
{mtSnowGolem, "SnowGolem"},
{mtOcelot, "Ocelot"},
{mtIronGolem, "IronGolem"},
{mtVillager, "Villager"},
};
for (size_t i = 0; i < ARRAYCOUNT(MobMap); i++)
{

View File

@ -6,26 +6,6 @@
cBlockInfo::cBlockInfo()
: m_LightValue(0x00)
, m_SpreadLightFalloff(0x0f)
, m_Transparent(false)
, m_OneHitDig(false)
, m_PistonBreakable(false)
, m_IsSnowable(false)
, m_IsSolid(true)
, m_FullyOccupiesVoxel(false)
, m_CanBeTerraformed(false)
, m_PlaceSound("")
, m_Handler(NULL)
{}
cBlockInfo::~cBlockInfo()
{
delete m_Handler;
@ -33,28 +13,6 @@ cBlockInfo::~cBlockInfo()
}
/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
It works only if it is called for the first time before the app spawns other threads. */
cBlockInfo & cBlockInfo::Get(BLOCKTYPE a_Type)
{
static cBlockInfo ms_Info[256];
static bool IsBlockInfoInitialized = false;
if (!IsBlockInfoInitialized)
{
cBlockInfo::Initialize(ms_Info);
IsBlockInfoInitialized = true;
}
return ms_Info[a_Type];
}
void cBlockInfo::Initialize(cBlockInfoArray & a_Info)
{
for (unsigned int i = 0; i < 256; ++i)

View File

@ -11,14 +11,27 @@ class cBlockHandler;
// tolua_begin
class cBlockInfo
{
public:
/** Returns the associated BlockInfo structure for the specified block type. */
static cBlockInfo & Get(BLOCKTYPE a_Type);
/** This accessor makes sure that the cBlockInfo structures are properly initialized exactly once.
It does so by using the C++ singleton approximation - storing the actual singleton as the function's static variable.
It works only if it is called for the first time before the app spawns other threads. */
static cBlockInfo & Get(BLOCKTYPE a_Type)
{
static cBlockInfo ms_Info[256];
static bool IsBlockInfoInitialized = false;
if (!IsBlockInfoInitialized)
{
cBlockInfo::Initialize(ms_Info);
IsBlockInfoInitialized = true;
}
return ms_Info[a_Type];
}
/** How much light do the blocks emit on their own? */
@ -78,7 +91,19 @@ protected:
typedef cBlockInfo cBlockInfoArray[256];
/** Creates a default BlockInfo structure, initializes all values to their defaults */
cBlockInfo();
cBlockInfo()
: m_LightValue(0x00)
, m_SpreadLightFalloff(0x0f)
, m_Transparent(false)
, m_OneHitDig(false)
, m_PistonBreakable(false)
, m_IsSnowable(false)
, m_IsSolid(true)
, m_FullyOccupiesVoxel(false)
, m_CanBeTerraformed(false)
, m_PlaceSound("")
, m_Handler(NULL)
{}
/** Cleans up the stored values */
~cBlockInfo();

View File

@ -151,7 +151,7 @@ public:
a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX - 1, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
// Spawn the wither:
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtWither);
// Award Achievement
a_WorldInterface.ForEachPlayer(PlayerCallback);
@ -181,7 +181,7 @@ public:
a_ChunkInterface.SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ - 1, E_BLOCK_AIR, 0);
// Spawn the wither:
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtWither);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtWither);
// Award Achievement
a_WorldInterface.ForEachPlayer(PlayerCallback);

View File

@ -4,7 +4,7 @@
#include "BlockHandler.h"
class cWorld;
class cBlockPistonHandler :

View File

@ -50,7 +50,7 @@ public:
int PosX = a_Chunk.GetPosX() * cChunkDef::Width + a_RelX;
int PosZ = a_Chunk.GetPosZ() * cChunkDef::Width + a_RelZ;
a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, cMonster::mtZombiePigman);
a_WorldInterface.SpawnMob(PosX, a_RelY, PosZ, mtZombiePigman);
}
virtual bool CanBeAt(cChunkInterface & a_ChunkInterface, int a_RelX, int a_RelY, int a_RelZ, const cChunk & a_Chunk) override

View File

@ -36,7 +36,7 @@ public:
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, E_BLOCK_AIR, 0);
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 1, a_BlockZ, E_BLOCK_AIR, 0);
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtSnowGolem);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtSnowGolem);
return;
}
@ -61,7 +61,7 @@ public:
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
// Spawn the golem:
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtIronGolem);
}
else if (
(a_ChunkInterface.GetBlock(a_BlockX, a_BlockY - 1, a_BlockZ + 1) == E_BLOCK_IRON_BLOCK) &&
@ -76,7 +76,7 @@ public:
a_ChunkInterface.FastSetBlock(a_BlockX, a_BlockY - 2, a_BlockZ, E_BLOCK_AIR, 0);
// Spawn the golem:
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, cMonster::mtIronGolem);
a_WorldInterface.SpawnMob(a_BlockX + 0.5, a_BlockY - 2, a_BlockZ + 0.5, mtIronGolem);
}
}

View File

@ -2,8 +2,74 @@
#include "Globals.h"
#include "ChunkInterface.h"
#include "ChunkMap.h"
#include "BlockHandler.h"
BLOCKTYPE cChunkInterface::GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
}
BLOCKTYPE cChunkInterface::GetBlock(const Vector3i & a_Pos)
{
return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z);
}
NIBBLETYPE cChunkInterface::GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
}
bool cChunkInterface::GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
/** Sets the block at the specified coords to the specified value.
Full processing, incl. updating neighbors, is performed.
*/
void cChunkInterface::SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
m_ChunkMap->SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
void cChunkInterface::SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
{
m_ChunkMap->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_MetaData);
}
void cChunkInterface::QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface)
{
m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_WorldInterface.GetWorldAge() + a_TickDelay, a_PreviousBlockType);
}
/** Sets the block at the specified coords to the specified value.
The replacement doesn't trigger block updates.
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
*/
void cChunkInterface::FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
void cChunkInterface::FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta);
}
void cChunkInterface::UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
}
bool cChunkInterface::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback)
{
return m_ChunkMap->ForEachChunkInRect(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ, a_Callback);
}
bool cChunkInterface::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
{
return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
}
bool cChunkInterface::DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z)
{
cBlockHandler * Handler = cBlockInfo::GetHandler(GetBlock(a_X, a_Y, a_Z));

View File

@ -1,13 +1,12 @@
#pragma once
#include "../ChunkMap.h"
#include "../ForEachChunkProvider.h"
#include "WorldInterface.h"
class cChunkMap;
class cChunkInterface:
public cForEachChunkProvider
@ -16,70 +15,34 @@ public:
cChunkInterface(cChunkMap * a_ChunkMap) : m_ChunkMap(a_ChunkMap) {}
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlock(a_BlockX, a_BlockY, a_BlockZ);
}
BLOCKTYPE GetBlock(const Vector3i & a_Pos)
{
return GetBlock(a_Pos.x, a_Pos.y, a_Pos.z);
}
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ)
{
return m_ChunkMap->GetBlockMeta(a_BlockX, a_BlockY, a_BlockZ);
}
BLOCKTYPE GetBlock(int a_BlockX, int a_BlockY, int a_BlockZ);
BLOCKTYPE GetBlock(const Vector3i & a_Pos);
NIBBLETYPE GetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ);
bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta)
{
return m_ChunkMap->GetBlockTypeMeta(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
bool GetBlockTypeMeta(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta);
/** Sets the block at the specified coords to the specified value.
Full processing, incl. updating neighbors, is performed.
*/
void SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
m_ChunkMap->SetBlock(a_WorldInterface, a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
void SetBlock(cWorldInterface & a_WorldInterface, int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData)
{
m_ChunkMap->SetBlockMeta(a_BlockX, a_BlockY, a_BlockZ, a_MetaData);
}
void SetBlockMeta(int a_BlockX, int a_BlockY, int a_BlockZ, NIBBLETYPE a_MetaData);
void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface)
{
m_ChunkMap->QueueSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta, a_WorldInterface.GetWorldAge() + a_TickDelay, a_PreviousBlockType);
}
void QueueSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, int a_TickDelay, BLOCKTYPE a_PreviousBlockType, cWorldInterface & a_WorldInterface);
/** Sets the block at the specified coords to the specified value.
The replacement doesn't trigger block updates.
The replaced blocks aren't checked for block entities (block entity is leaked if it exists at this block)
*/
void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
m_ChunkMap->FastSetBlock(a_BlockX, a_BlockY, a_BlockZ, a_BlockType, a_BlockMeta);
}
void FastSetBlock(int a_BlockX, int a_BlockY, int a_BlockZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta)
{
FastSetBlock( a_Pos.x, a_Pos.y, a_Pos.z, a_BlockType, a_BlockMeta);
}
void FastSetBlock(const Vector3i & a_Pos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta);
void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ)
{
m_ChunkMap->UseBlockEntity(a_Player, a_BlockX, a_BlockY, a_BlockZ);
}
void UseBlockEntity(cPlayer * a_Player, int a_BlockX, int a_BlockY, int a_BlockZ);
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override
{
return m_ChunkMap->ForEachChunkInRect(a_MinChunkX, a_MaxChunkX, a_MinChunkZ, a_MaxChunkZ, a_Callback);
}
virtual bool ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback) override;
virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override
{
return m_ChunkMap->WriteBlockArea(a_Area, a_MinBlockX, a_MinBlockY, a_MinBlockZ, a_DataTypes);
}
virtual bool WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes) override;
bool DigBlock(cWorldInterface & a_WorldInterface, int a_X, int a_Y, int a_Z);

View File

@ -2,14 +2,15 @@
#pragma once
#include "BroadcastInterface.h"
#include "../Mobs/Monster.h"
#include "../Mobs/MonsterTypes.h"
class cItems;
typedef cItemCallback<cBlockEntity> cBlockEntityCallback;
class cMonster;
class cPlayer;
class cWorldInterface
@ -33,7 +34,7 @@ public:
virtual void SpawnItemPickups(const cItems & a_Pickups, double a_BlockX, double a_BlockY, double a_BlockZ, double a_SpeedX, double a_SpeedY, double a_SpeedZ, bool IsPlayerCreated = false) = 0;
/** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) = 0;
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) = 0;
/** Calls the callback for the block entity at the specified coords; returns false if there's no block entity at those coords, true if found */
virtual bool DoWithBlockEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cBlockEntityCallback & a_Callback) = 0;

View File

@ -334,10 +334,10 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
cMonster * Monster = (cMonster *)this;
switch (Monster->GetMobType())
{
case cMonster::mtSkeleton:
case cMonster::mtZombie:
case cMonster::mtWither:
case cMonster::mtZombiePigman:
case mtSkeleton:
case mtZombie:
case mtWither:
case mtZombiePigman:
{
a_TDI.FinalDamage += (int)ceil(2.5 * SmiteLevel);
break;
@ -352,9 +352,9 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
cMonster * Monster = (cMonster *)this;
switch (Monster->GetMobType())
{
case cMonster::mtSpider:
case cMonster::mtCaveSpider:
case cMonster::mtSilverfish:
case mtSpider:
case mtCaveSpider:
case mtSilverfish:
{
a_TDI.RawDamage += (int)ceil(2.5 * BaneOfArthropodsLevel);
// TODO: Add slowness effect
@ -384,9 +384,9 @@ bool cEntity::DoTakeDamage(TakeDamageInfo & a_TDI)
cMonster * Monster = (cMonster *)this;
switch (Monster->GetMobType())
{
case cMonster::mtGhast:
case cMonster::mtZombiePigman:
case cMonster::mtMagmaCube:
case mtGhast:
case mtZombiePigman:
case mtMagmaCube:
{
break;
};

View File

@ -349,8 +349,8 @@ void cEntityEffectPoison::OnTick(cPawn & a_Target)
// Doesn't effect undead mobs, spiders
if (
Target.IsUndead() ||
(Target.GetMobType() == cMonster::mtSpider) ||
(Target.GetMobType() == cMonster::mtCaveSpider)
(Target.GetMobType() == mtSpider) ||
(Target.GetMobType() == mtCaveSpider)
)
{
return;

View File

@ -2003,8 +2003,8 @@ void cPlayer::UpdateMovementStats(const Vector3d & a_DeltaPos)
cMonster * Monster = (cMonster *)m_AttachedTo;
switch (Monster->GetMobType())
{
case cMonster::mtPig: m_Stats.AddValue(statDistPig, Value); break;
case cMonster::mtHorse: m_Stats.AddValue(statDistHorse, Value); break;
case mtPig: m_Stats.AddValue(statDistPig, Value); break;
case mtHorse: m_Stats.AddValue(statDistHorse, Value); break;
default: break;
}
break;

View File

@ -48,13 +48,13 @@ void cThrownEggEntity::TrySpawnChicken(const Vector3d & a_HitPos)
{
if (m_World->GetTickRandomNumber(7) == 1)
{
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
}
else if (m_World->GetTickRandomNumber(32) == 1)
{
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, cMonster::mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
m_World->SpawnMob(a_HitPos.x, a_HitPos.y, a_HitPos.z, mtChicken);
}
}

View File

@ -32,8 +32,8 @@ void cThrownSnowballEntity::OnHitEntity(cEntity & a_EntityHit, const Vector3d &
int TotalDamage = 0;
if (a_EntityHit.IsMob())
{
cMonster::eType MobType = ((cMonster &) a_EntityHit).GetMobType();
if (MobType == cMonster::mtBlaze)
eMonsterType MobType = ((cMonster &) a_EntityHit).GetMobType();
if (MobType == mtBlaze)
{
TotalDamage = 3;
}

View File

@ -15,6 +15,7 @@
#include "../Simulator/FluidSimulator.h" // for cFluidSimulator::CanWashAway()
#include "../Simulator/FireSimulator.h"
#include "../World.h"
#include "inifile/iniFile.h"

View File

@ -261,6 +261,27 @@ void inline LOGERROR(const char* a_Format, ...)
vprintf(a_Format, argList);
va_end(argList);
}
void inline LOGWARNING(const char* a_Format, ...) FORMATSTRING(1, 2);
void inline LOGWARNING(const char* a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
vprintf(a_Format, argList);
va_end(argList);
}
void inline LOGD(const char* a_Format, ...) FORMATSTRING(1, 2);
void inline LOGD(const char* a_Format, ...)
{
va_list argList;
va_start(argList, a_Format);
vprintf(a_Format, argList);
va_end(argList);
}
#endif

View File

@ -33,9 +33,9 @@ public:
a_BlockY--;
}
cMonster::eType MonsterType = ItemDamageToMonsterType(a_Item.m_ItemDamage);
eMonsterType MonsterType = ItemDamageToMonsterType(a_Item.m_ItemDamage);
if (
(MonsterType != cMonster::mtInvalidType) && // Valid monster type
(MonsterType != mtInvalidType) && // Valid monster type
(a_World->SpawnMob(a_BlockX + 0.5, a_BlockY, a_BlockZ + 0.5, MonsterType) >= 0)) // Spawning succeeded
{
if (!a_Player->IsGameModeCreative())
@ -52,36 +52,36 @@ public:
/** Converts the Spawn egg item damage to the monster type to spawn.
Returns mtInvalidType for invalid damage values. */
static cMonster::eType ItemDamageToMonsterType(short a_ItemDamage)
static eMonsterType ItemDamageToMonsterType(short a_ItemDamage)
{
switch (a_ItemDamage)
{
case E_META_SPAWN_EGG_BAT: return cMonster::mtBat;
case E_META_SPAWN_EGG_BLAZE: return cMonster::mtBlaze;
case E_META_SPAWN_EGG_CAVE_SPIDER: return cMonster::mtCaveSpider;
case E_META_SPAWN_EGG_CHICKEN: return cMonster::mtChicken;
case E_META_SPAWN_EGG_COW: return cMonster::mtCow;
case E_META_SPAWN_EGG_CREEPER: return cMonster::mtCreeper;
case E_META_SPAWN_EGG_ENDERMAN: return cMonster::mtEnderman;
case E_META_SPAWN_EGG_GHAST: return cMonster::mtGhast;
case E_META_SPAWN_EGG_HORSE: return cMonster::mtHorse;
case E_META_SPAWN_EGG_MAGMA_CUBE: return cMonster::mtMagmaCube;
case E_META_SPAWN_EGG_MOOSHROOM: return cMonster::mtMooshroom;
case E_META_SPAWN_EGG_OCELOT: return cMonster::mtOcelot;
case E_META_SPAWN_EGG_PIG: return cMonster::mtPig;
case E_META_SPAWN_EGG_SHEEP: return cMonster::mtSheep;
case E_META_SPAWN_EGG_SILVERFISH: return cMonster::mtSilverfish;
case E_META_SPAWN_EGG_SKELETON: return cMonster::mtSkeleton;
case E_META_SPAWN_EGG_SLIME: return cMonster::mtSlime;
case E_META_SPAWN_EGG_SPIDER: return cMonster::mtSpider;
case E_META_SPAWN_EGG_SQUID: return cMonster::mtSquid;
case E_META_SPAWN_EGG_VILLAGER: return cMonster::mtVillager;
case E_META_SPAWN_EGG_WITCH: return cMonster::mtWitch;
case E_META_SPAWN_EGG_WOLF: return cMonster::mtWolf;
case E_META_SPAWN_EGG_ZOMBIE: return cMonster::mtZombie;
case E_META_SPAWN_EGG_ZOMBIE_PIGMAN: return cMonster::mtZombiePigman;
case E_META_SPAWN_EGG_BAT: return mtBat;
case E_META_SPAWN_EGG_BLAZE: return mtBlaze;
case E_META_SPAWN_EGG_CAVE_SPIDER: return mtCaveSpider;
case E_META_SPAWN_EGG_CHICKEN: return mtChicken;
case E_META_SPAWN_EGG_COW: return mtCow;
case E_META_SPAWN_EGG_CREEPER: return mtCreeper;
case E_META_SPAWN_EGG_ENDERMAN: return mtEnderman;
case E_META_SPAWN_EGG_GHAST: return mtGhast;
case E_META_SPAWN_EGG_HORSE: return mtHorse;
case E_META_SPAWN_EGG_MAGMA_CUBE: return mtMagmaCube;
case E_META_SPAWN_EGG_MOOSHROOM: return mtMooshroom;
case E_META_SPAWN_EGG_OCELOT: return mtOcelot;
case E_META_SPAWN_EGG_PIG: return mtPig;
case E_META_SPAWN_EGG_SHEEP: return mtSheep;
case E_META_SPAWN_EGG_SILVERFISH: return mtSilverfish;
case E_META_SPAWN_EGG_SKELETON: return mtSkeleton;
case E_META_SPAWN_EGG_SLIME: return mtSlime;
case E_META_SPAWN_EGG_SPIDER: return mtSpider;
case E_META_SPAWN_EGG_SQUID: return mtSquid;
case E_META_SPAWN_EGG_VILLAGER: return mtVillager;
case E_META_SPAWN_EGG_WITCH: return mtWitch;
case E_META_SPAWN_EGG_WOLF: return mtWolf;
case E_META_SPAWN_EGG_ZOMBIE: return mtZombie;
case E_META_SPAWN_EGG_ZOMBIE_PIGMAN: return mtZombiePigman;
}
return cMonster::mtInvalidType;
return mtInvalidType;
}
} ;

View File

@ -8,12 +8,12 @@
cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily, const std::set<cMonster::eType>& a_AllowedTypes) :
cMobSpawner::cMobSpawner(cMonster::eFamily a_MonsterFamily, const std::set<eMonsterType>& a_AllowedTypes) :
m_MonsterFamily(a_MonsterFamily),
m_NewPack(true),
m_MobType(cMonster::mtInvalidType)
m_MobType(mtInvalidType)
{
for (std::set<cMonster::eType>::const_iterator itr = a_AllowedTypes.begin(); itr != a_AllowedTypes.end(); ++itr)
for (std::set<eMonsterType>::const_iterator itr = a_AllowedTypes.begin(); itr != a_AllowedTypes.end(); ++itr)
{
if (cMonster::FamilyFromType(*itr) == a_MonsterFamily)
{
@ -44,9 +44,9 @@ bool cMobSpawner::CheckPackCenter(BLOCKTYPE a_BlockType)
void cMobSpawner::addIfAllowed(cMonster::eType toAdd, std::set<cMonster::eType>& toAddIn)
void cMobSpawner::addIfAllowed(eMonsterType toAdd, std::set<eMonsterType>& toAddIn)
{
std::set<cMonster::eType>::iterator itr = m_AllowedTypes.find(toAdd);
std::set<eMonsterType>::iterator itr = m_AllowedTypes.find(toAdd);
if (itr != m_AllowedTypes.end())
{
toAddIn.insert(toAdd);
@ -57,49 +57,49 @@ void cMobSpawner::addIfAllowed(cMonster::eType toAdd, std::set<cMonster::eType>&
cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
eMonsterType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
{
std::set<cMonster::eType> allowedMobs;
std::set<eMonsterType> allowedMobs;
if (a_Biome == biMushroomIsland || a_Biome == biMushroomShore)
{
addIfAllowed(cMonster::mtMooshroom, allowedMobs);
addIfAllowed(mtMooshroom, allowedMobs);
}
else if (a_Biome == biNether)
{
addIfAllowed(cMonster::mtGhast, allowedMobs);
addIfAllowed(cMonster::mtZombiePigman, allowedMobs);
addIfAllowed(cMonster::mtMagmaCube, allowedMobs);
addIfAllowed(mtGhast, allowedMobs);
addIfAllowed(mtZombiePigman, allowedMobs);
addIfAllowed(mtMagmaCube, allowedMobs);
}
else if (a_Biome == biEnd)
{
addIfAllowed(cMonster::mtEnderman, allowedMobs);
addIfAllowed(mtEnderman, allowedMobs);
}
else
{
addIfAllowed(cMonster::mtBat, allowedMobs);
addIfAllowed(cMonster::mtSpider, allowedMobs);
addIfAllowed(cMonster::mtZombie, allowedMobs);
addIfAllowed(cMonster::mtSkeleton, allowedMobs);
addIfAllowed(cMonster::mtCreeper, allowedMobs);
addIfAllowed(cMonster::mtSquid, allowedMobs);
addIfAllowed(mtBat, allowedMobs);
addIfAllowed(mtSpider, allowedMobs);
addIfAllowed(mtZombie, allowedMobs);
addIfAllowed(mtSkeleton, allowedMobs);
addIfAllowed(mtCreeper, allowedMobs);
addIfAllowed(mtSquid, allowedMobs);
if (a_Biome != biDesert && a_Biome != biBeach && a_Biome != biOcean)
{
addIfAllowed(cMonster::mtSheep, allowedMobs);
addIfAllowed(cMonster::mtPig, allowedMobs);
addIfAllowed(cMonster::mtCow, allowedMobs);
addIfAllowed(cMonster::mtChicken, allowedMobs);
addIfAllowed(cMonster::mtEnderman, allowedMobs);
addIfAllowed(cMonster::mtSlime, allowedMobs); // MG TODO : much more complicated rule
addIfAllowed(mtSheep, allowedMobs);
addIfAllowed(mtPig, allowedMobs);
addIfAllowed(mtCow, allowedMobs);
addIfAllowed(mtChicken, allowedMobs);
addIfAllowed(mtEnderman, allowedMobs);
addIfAllowed(mtSlime, allowedMobs); // MG TODO : much more complicated rule
if (a_Biome == biForest || a_Biome == biForestHills || a_Biome == biTaiga || a_Biome == biTaigaHills)
{
addIfAllowed(cMonster::mtWolf, allowedMobs);
addIfAllowed(mtWolf, allowedMobs);
}
else if (a_Biome == biJungle || a_Biome == biJungleHills)
{
addIfAllowed(cMonster::mtOcelot, allowedMobs);
addIfAllowed(mtOcelot, allowedMobs);
}
}
}
@ -107,7 +107,7 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
size_t allowedMobsSize = allowedMobs.size();
if (allowedMobsSize > 0)
{
std::set<cMonster::eType>::iterator itr = allowedMobs.begin();
std::set<eMonsterType>::iterator itr = allowedMobs.begin();
int iRandom = m_Random.NextInt((int)allowedMobsSize, a_Biome);
for (int i = 0; i < iRandom; i++)
@ -117,14 +117,14 @@ cMonster::eType cMobSpawner::ChooseMobType(EMCSBiome a_Biome)
return *itr;
}
return cMonster::mtInvalidType;
return mtInvalidType;
}
bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome)
bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, eMonsterType a_MobType, EMCSBiome a_Biome)
{
BLOCKTYPE TargetBlock = E_BLOCK_AIR;
if (m_AllowedTypes.find(a_MobType) != m_AllowedTypes.end() && a_Chunk->UnboundedRelGetBlockType(a_RelX, a_RelY, a_RelZ, TargetBlock))
@ -143,21 +143,21 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
switch (a_MobType)
{
case cMonster::mtSquid:
case mtSquid:
{
return IsBlockWater(TargetBlock) && (a_RelY >= 45) && (a_RelY <= 62);
}
case cMonster::mtBat:
case mtBat:
{
return (a_RelY <= 63) && (BlockLight <= 4) && (SkyLight <= 4) && (TargetBlock == E_BLOCK_AIR) && !cBlockInfo::IsTransparent(BlockAbove);
}
case cMonster::mtChicken:
case cMonster::mtCow:
case cMonster::mtPig:
case cMonster::mtHorse:
case cMonster::mtSheep:
case mtChicken:
case mtCow:
case mtPig:
case mtHorse:
case mtSheep:
{
return (
(TargetBlock == E_BLOCK_AIR) &&
@ -168,7 +168,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
case cMonster::mtOcelot:
case mtOcelot:
{
return (
(TargetBlock == E_BLOCK_AIR) &&
@ -181,7 +181,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
case cMonster::mtEnderman:
case mtEnderman:
{
if (a_RelY < 250)
{
@ -202,7 +202,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
break;
}
case cMonster::mtSpider:
case mtSpider:
{
bool CanSpawn = true;
bool HasFloor = false;
@ -228,9 +228,9 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
return CanSpawn && HasFloor && (SkyLight <= 7) && (BlockLight <= 7);
}
case cMonster::mtCreeper:
case cMonster::mtSkeleton:
case cMonster::mtZombie:
case mtCreeper:
case mtSkeleton:
case mtZombie:
{
return (
(TargetBlock == E_BLOCK_AIR) &&
@ -242,8 +242,8 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
case cMonster::mtMagmaCube:
case cMonster::mtSlime:
case mtMagmaCube:
case mtSlime:
{
return (
(TargetBlock == E_BLOCK_AIR) &&
@ -255,8 +255,8 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
case cMonster::mtGhast:
case cMonster::mtZombiePigman:
case mtGhast:
case mtZombiePigman:
{
return (
(TargetBlock == E_BLOCK_AIR) &&
@ -266,7 +266,7 @@ bool cMobSpawner::CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_R
);
}
case cMonster::mtWolf:
case mtWolf:
{
return (
(TargetBlock == E_BLOCK_GRASS) &&
@ -305,15 +305,15 @@ cMonster* cMobSpawner::TryToSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY,
if (m_NewPack)
{
m_MobType = ChooseMobType(a_Biome);
if (m_MobType == cMonster::mtInvalidType)
if (m_MobType == mtInvalidType)
{
return toReturn;
}
if (m_MobType == cMonster::mtWolf)
if (m_MobType == mtWolf)
{
a_MaxPackSize = 8;
}
else if (m_MobType == cMonster::mtGhast)
else if (m_MobType == mtGhast)
{
a_MaxPackSize = 1;
}

View File

@ -30,7 +30,7 @@ public :
// a_AllowedTypes is the set of types allowed for mobs it will spawn. Empty set
// would result in no spawn at all
// Allowed mobs thah are not of the right Family will not be include (no warning)
cMobSpawner(cMonster::eFamily MobFamily, const std::set<cMonster::eType> & a_AllowedTypes);
cMobSpawner(cMonster::eFamily MobFamily, const std::set<eMonsterType> & a_AllowedTypes);
/// Check if specified block can be a Pack center for this spawner
bool CheckPackCenter(BLOCKTYPE a_BlockType);
@ -53,20 +53,20 @@ public :
protected :
// return true if specified type of mob can spawn on specified block
bool CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, cMonster::eType a_MobType, EMCSBiome a_Biome);
bool CanSpawnHere(cChunk * a_Chunk, int a_RelX, int a_RelY, int a_RelZ, eMonsterType a_MobType, EMCSBiome a_Biome);
// return a random type that can spawn on specified biome.
// returns E_ENTITY_TYPE_DONOTUSE if none is possible
cMonster::eType ChooseMobType(EMCSBiome a_Biome);
eMonsterType ChooseMobType(EMCSBiome a_Biome);
// add toAdd inside toAddIn, if toAdd is in m_AllowedTypes
void addIfAllowed(cMonster::eType toAdd, std::set<cMonster::eType> & toAddIn);
void addIfAllowed(eMonsterType toAdd, std::set<eMonsterType> & toAddIn);
protected :
cMonster::eFamily m_MonsterFamily;
std::set<cMonster::eType> m_AllowedTypes;
std::set<eMonsterType> m_AllowedTypes;
bool m_NewPack;
cMonster::eType m_MobType;
eMonsterType m_MobType;
std::set<cMonster*> m_Spawned;
cFastRandom m_Random;
} ;

View File

@ -11,7 +11,7 @@
cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
cAggressiveMonster::cAggressiveMonster(const AString & a_ConfigName, eMonsterType 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 = AGGRESSIVE;

View File

@ -14,7 +14,7 @@ class cAggressiveMonster :
public:
cAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
cAggressiveMonster(const AString & a_ConfigName, eMonsterType 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;

View File

@ -24,38 +24,38 @@ The strings need to be lowercase (for more efficient comparisons in StringToMobT
*/
static const struct
{
cMonster::eType m_Type;
eMonsterType m_Type;
const char * m_lcName;
} g_MobTypeNames[] =
{
{cMonster::mtBat, "bat"},
{cMonster::mtBlaze, "blaze"},
{cMonster::mtCaveSpider, "cavespider"},
{cMonster::mtChicken, "chicken"},
{cMonster::mtCow, "cow"},
{cMonster::mtCreeper, "creeper"},
{cMonster::mtEnderman, "enderman"},
{cMonster::mtEnderDragon, "enderdragon"},
{cMonster::mtGhast, "ghast"},
{cMonster::mtHorse, "horse"},
{cMonster::mtIronGolem, "irongolem"},
{cMonster::mtMagmaCube, "magmacube"},
{cMonster::mtMooshroom, "mooshroom"},
{cMonster::mtOcelot, "ocelot"},
{cMonster::mtPig, "pig"},
{cMonster::mtSheep, "sheep"},
{cMonster::mtSilverfish, "silverfish"},
{cMonster::mtSkeleton, "skeleton"},
{cMonster::mtSlime, "slime"},
{cMonster::mtSnowGolem, "snowgolem"},
{cMonster::mtSpider, "spider"},
{cMonster::mtSquid, "squid"},
{cMonster::mtVillager, "villager"},
{cMonster::mtWitch, "witch"},
{cMonster::mtWither, "wither"},
{cMonster::mtWolf, "wolf"},
{cMonster::mtZombie, "zombie"},
{cMonster::mtZombiePigman, "zombiepigman"},
{mtBat, "bat"},
{mtBlaze, "blaze"},
{mtCaveSpider, "cavespider"},
{mtChicken, "chicken"},
{mtCow, "cow"},
{mtCreeper, "creeper"},
{mtEnderman, "enderman"},
{mtEnderDragon, "enderdragon"},
{mtGhast, "ghast"},
{mtHorse, "horse"},
{mtIronGolem, "irongolem"},
{mtMagmaCube, "magmacube"},
{mtMooshroom, "mooshroom"},
{mtOcelot, "ocelot"},
{mtPig, "pig"},
{mtSheep, "sheep"},
{mtSilverfish, "silverfish"},
{mtSkeleton, "skeleton"},
{mtSlime, "slime"},
{mtSnowGolem, "snowgolem"},
{mtSpider, "spider"},
{mtSquid, "squid"},
{mtVillager, "villager"},
{mtWitch, "witch"},
{mtWither, "wither"},
{mtWolf, "wolf"},
{mtZombie, "zombie"},
{mtZombiePigman, "zombiepigman"},
} ;
@ -65,7 +65,7 @@ static const struct
////////////////////////////////////////////////////////////////////////////////
// cMonster:
cMonster::cMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
cMonster::cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height)
: super(etMonster, a_Width, a_Height)
, m_EMState(IDLE)
, m_EMPersonality(AGGRESSIVE)
@ -485,50 +485,50 @@ void cMonster::KilledBy(TakeDamageInfo & a_TDI)
switch (m_MobType)
{
// Animals
case cMonster::mtChicken:
case cMonster::mtCow:
case cMonster::mtHorse:
case cMonster::mtPig:
case cMonster::mtSheep:
case cMonster::mtSquid:
case cMonster::mtMooshroom:
case cMonster::mtOcelot:
case cMonster::mtWolf:
case mtChicken:
case mtCow:
case mtHorse:
case mtPig:
case mtSheep:
case mtSquid:
case mtMooshroom:
case mtOcelot:
case mtWolf:
{
Reward = m_World->GetTickRandomNumber(2) + 1;
break;
}
// Monsters
case cMonster::mtCaveSpider:
case cMonster::mtCreeper:
case cMonster::mtEnderman:
case cMonster::mtGhast:
case cMonster::mtSilverfish:
case cMonster::mtSkeleton:
case cMonster::mtSpider:
case cMonster::mtWitch:
case cMonster::mtZombie:
case cMonster::mtZombiePigman:
case cMonster::mtSlime:
case cMonster::mtMagmaCube:
case mtCaveSpider:
case mtCreeper:
case mtEnderman:
case mtGhast:
case mtSilverfish:
case mtSkeleton:
case mtSpider:
case mtWitch:
case mtZombie:
case mtZombiePigman:
case mtSlime:
case mtMagmaCube:
{
Reward = 6 + (m_World->GetTickRandomNumber(2));
break;
}
case cMonster::mtBlaze:
case mtBlaze:
{
Reward = 10;
break;
}
// Bosses
case cMonster::mtEnderDragon:
case mtEnderDragon:
{
Reward = 12000;
break;
}
case cMonster::mtWither:
case mtWither:
{
Reward = 50;
break;
@ -697,7 +697,7 @@ bool cMonster::IsUndead(void)
AString cMonster::MobTypeToString(cMonster::eType a_MobType)
AString cMonster::MobTypeToString(eMonsterType a_MobType)
{
// Mob types aren't sorted, so we need to search linearly:
for (size_t i = 0; i < ARRAYCOUNT(g_MobTypeNames); i++)
@ -716,7 +716,7 @@ AString cMonster::MobTypeToString(cMonster::eType a_MobType)
cMonster::eType cMonster::StringToMobType(const AString & a_Name)
eMonsterType cMonster::StringToMobType(const AString & a_Name)
{
AString lcName = StrToLower(a_Name);
@ -757,7 +757,7 @@ cMonster::eType cMonster::StringToMobType(const AString & a_Name)
cMonster::eFamily cMonster::FamilyFromType(eType a_Type)
cMonster::eFamily cMonster::FamilyFromType(eMonsterType a_Type)
{
// Passive-agressive mobs are counted in mob spawning code as passive
@ -822,7 +822,7 @@ int cMonster::GetSpawnDelay(cMonster::eFamily a_MobFamily)
cMonster * cMonster::NewMonsterFromType(cMonster::eType a_MobType)
cMonster * cMonster::NewMonsterFromType(eMonsterType a_MobType)
{
cFastRandom Random;
cMonster * toReturn = NULL;

View File

@ -6,6 +6,7 @@
#include "../BlockID.h"
#include "../Item.h"
#include "../Enchantments.h"
#include "MonsterTypes.h"
@ -15,50 +16,13 @@ class cClientHandle;
class cWorld;
// tolua_begin
class cMonster :
public cPawn
{
typedef cPawn super;
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,
mtChicken = E_META_SPAWN_EGG_CHICKEN,
mtCow = E_META_SPAWN_EGG_COW,
mtCreeper = E_META_SPAWN_EGG_CREEPER,
mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON,
mtEnderman = E_META_SPAWN_EGG_ENDERMAN,
mtGhast = E_META_SPAWN_EGG_GHAST,
mtGiant = E_META_SPAWN_EGG_GIANT,
mtHorse = E_META_SPAWN_EGG_HORSE,
mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM,
mtMagmaCube = E_META_SPAWN_EGG_MAGMA_CUBE,
mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM,
mtOcelot = E_META_SPAWN_EGG_OCELOT,
mtPig = E_META_SPAWN_EGG_PIG,
mtSheep = E_META_SPAWN_EGG_SHEEP,
mtSilverfish = E_META_SPAWN_EGG_SILVERFISH,
mtSkeleton = E_META_SPAWN_EGG_SKELETON,
mtSlime = E_META_SPAWN_EGG_SLIME,
mtSnowGolem = E_META_SPAWN_EGG_SNOW_GOLEM,
mtSpider = E_META_SPAWN_EGG_SPIDER,
mtSquid = E_META_SPAWN_EGG_SQUID,
mtVillager = E_META_SPAWN_EGG_VILLAGER,
mtWitch = E_META_SPAWN_EGG_WITCH,
mtWither = E_META_SPAWN_EGG_WITHER,
mtWolf = E_META_SPAWN_EGG_WOLF,
mtZombie = E_META_SPAWN_EGG_ZOMBIE,
mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
} ;
enum eFamily
{
mfHostile = 0, // Spider, Zombies ...
@ -80,7 +44,7 @@ public:
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, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
cMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
CLASS_PROTODEF(cMonster)
@ -96,7 +60,7 @@ public:
virtual bool ReachedDestination(void);
// tolua_begin
eType GetMobType(void) const {return m_MobType; }
eMonsterType GetMobType(void) const {return m_MobType; }
eFamily GetMobFamily(void) const;
// tolua_end
@ -146,13 +110,13 @@ public:
// tolua_begin
/// Translates MobType enum to a string, empty string if unknown
static AString MobTypeToString(eType a_MobType);
static AString MobTypeToString(eMonsterType a_MobType);
/// Translates MobType string to the enum, mtInvalidType if not recognized
static eType StringToMobType(const AString & a_MobTypeName);
static eMonsterType StringToMobType(const AString & a_MobTypeName);
/// Returns the mob family based on the type
static eFamily FamilyFromType(eType a_MobType);
static eFamily FamilyFromType(eMonsterType a_MobType);
/// Returns the spawn delay (number of game ticks between spawn attempts) for the given mob family
static int GetSpawnDelay(cMonster::eFamily a_MobFamily);
@ -163,7 +127,7 @@ public:
a_MobType is the type of the mob to be created
Asserts and returns null if mob type is not specified
*/
static cMonster * NewMonsterFromType(eType a_MobType);
static cMonster * NewMonsterFromType(eMonsterType a_MobType);
protected:
@ -227,7 +191,7 @@ protected:
float m_IdleInterval;
float m_DestroyTimer;
eType m_MobType;
eMonsterType m_MobType;
AString m_SoundHurt;
AString m_SoundDeath;

41
src/Mobs/MonsterTypes.h Normal file
View File

@ -0,0 +1,41 @@
#pragma once
/// This identifies individual monster type, as well as their network type-ID
// tolua_begin
enum eMonsterType
{
mtInvalidType = -1,
mtBat = E_META_SPAWN_EGG_BAT,
mtBlaze = E_META_SPAWN_EGG_BLAZE,
mtCaveSpider = E_META_SPAWN_EGG_CAVE_SPIDER,
mtChicken = E_META_SPAWN_EGG_CHICKEN,
mtCow = E_META_SPAWN_EGG_COW,
mtCreeper = E_META_SPAWN_EGG_CREEPER,
mtEnderDragon = E_META_SPAWN_EGG_ENDER_DRAGON,
mtEnderman = E_META_SPAWN_EGG_ENDERMAN,
mtGhast = E_META_SPAWN_EGG_GHAST,
mtGiant = E_META_SPAWN_EGG_GIANT,
mtHorse = E_META_SPAWN_EGG_HORSE,
mtIronGolem = E_META_SPAWN_EGG_IRON_GOLEM,
mtMagmaCube = E_META_SPAWN_EGG_MAGMA_CUBE,
mtMooshroom = E_META_SPAWN_EGG_MOOSHROOM,
mtOcelot = E_META_SPAWN_EGG_OCELOT,
mtPig = E_META_SPAWN_EGG_PIG,
mtSheep = E_META_SPAWN_EGG_SHEEP,
mtSilverfish = E_META_SPAWN_EGG_SILVERFISH,
mtSkeleton = E_META_SPAWN_EGG_SKELETON,
mtSlime = E_META_SPAWN_EGG_SLIME,
mtSnowGolem = E_META_SPAWN_EGG_SNOW_GOLEM,
mtSpider = E_META_SPAWN_EGG_SPIDER,
mtSquid = E_META_SPAWN_EGG_SQUID,
mtVillager = E_META_SPAWN_EGG_VILLAGER,
mtWitch = E_META_SPAWN_EGG_WITCH,
mtWither = E_META_SPAWN_EGG_WITHER,
mtWolf = E_META_SPAWN_EGG_WOLF,
mtZombie = E_META_SPAWN_EGG_ZOMBIE,
mtZombiePigman = E_META_SPAWN_EGG_ZOMBIE_PIGMAN,
} ;
// tolua_end

View File

@ -67,7 +67,7 @@ void cMooshroom::OnRightClicked(cPlayer & a_Player)
cItems Drops;
Drops.push_back(cItem(E_BLOCK_RED_MUSHROOM, 5, 0));
m_World->SpawnItemPickups(Drops, GetPosX(), GetPosY(), GetPosZ(), 10);
m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), cMonster::mtCow);
m_World->SpawnMob(GetPosX(), GetPosY(), GetPosZ(), mtCow);
Destroy();
} break;
}

View File

@ -9,7 +9,7 @@
cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
cPassiveAggressiveMonster::cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType 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;

View File

@ -13,7 +13,7 @@ class cPassiveAggressiveMonster :
typedef cAggressiveMonster super;
public:
cPassiveAggressiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
cPassiveAggressiveMonster(const AString & a_ConfigName, eMonsterType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
virtual bool DoTakeDamage(TakeDamageInfo & a_TDI) override;
} ;

View File

@ -8,7 +8,7 @@
cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height) :
cPassiveMonster::cPassiveMonster(const AString & a_ConfigName, eMonsterType 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;

View File

@ -13,7 +13,7 @@ class cPassiveMonster :
typedef cMonster super;
public:
cPassiveMonster(const AString & a_ConfigName, eType a_MobType, const AString & a_SoundHurt, const AString & a_SoundDeath, double a_Width, double a_Height);
cPassiveMonster(const AString & a_ConfigName, eMonsterType 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;

View File

@ -1946,7 +1946,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
{
switch (a_Mob.GetMobType())
{
case cMonster::mtCreeper:
case mtCreeper:
{
WriteByte(0x10);
WriteChar(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1); // Blowing up?
@ -1954,25 +1954,25 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
WriteByte(((const cCreeper &)a_Mob).IsCharged() ? 1 : 0); // Lightning-charged?
break;
}
case cMonster::mtBat:
case mtBat:
{
WriteByte(0x10);
WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0); // Upside down?
break;
}
case cMonster::mtPig:
case mtPig:
{
WriteByte(0x10);
WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0); // Saddled?
break;
}
case cMonster::mtVillager:
case mtVillager:
{
WriteByte(0x50);
WriteInt(((const cVillager &)a_Mob).GetVilType()); // What sort of TESTIFICATE?
break;
}
case cMonster::mtZombie:
case mtZombie:
{
WriteByte(0xC);
WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0); // Baby zombie?
@ -1982,13 +1982,13 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
WriteByte(((const cZombie &)a_Mob).IsConverting() ? 1 : 0); // Converted-but-converting-back zombllager?
break;
}
case cMonster::mtGhast:
case mtGhast:
{
WriteByte(0x10);
WriteByte(((const cGhast &)a_Mob).IsCharging()); // About to spit a flameball?
break;
}
case cMonster::mtWolf:
case mtWolf:
{
Byte WolfStatus = 0;
if (((const cWolf &)a_Mob).IsSitting())
@ -2012,7 +2012,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
WriteByte(((const cWolf &)a_Mob).IsBegging() ? 1 : 0); // Ultra cute mode?
break;
}
case cMonster::mtSheep:
case mtSheep:
{
// [1](1111)
// [] = Is sheared? () = Color, from 0 to 15
@ -2028,7 +2028,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
WriteByte(SheepMetadata);
break;
}
case cMonster::mtEnderman:
case mtEnderman:
{
WriteByte(0x10);
WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock())); // Block that he stole from your house
@ -2038,19 +2038,19 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
WriteByte(((const cEnderman &)a_Mob).IsScreaming() ? 1 : 0); // Screaming at your face?
break;
}
case cMonster::mtSkeleton:
case mtSkeleton:
{
WriteByte(0xD);
WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0); // It's a skeleton, but it's not
break;
}
case cMonster::mtWitch:
case mtWitch:
{
WriteByte(0x15);
WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0); // Aggravated? Doesn't seem to do anything
break;
}
case cMonster::mtWither:
case mtWither:
{
WriteByte(0x54); // Int at index 20
WriteInt((Int32)((const cWither &)a_Mob).GetWitherInvulnerableTicks());
@ -2058,11 +2058,11 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
WriteFloat((float)(a_Mob.GetHealth()));
break;
}
case cMonster::mtSlime:
case cMonster::mtMagmaCube:
case mtSlime:
case mtMagmaCube:
{
WriteByte(0x10);
if (a_Mob.GetMobType() == cMonster::mtSlime)
if (a_Mob.GetMobType() == mtSlime)
{
WriteByte((Byte)((const cSlime &)a_Mob).GetSize()); // Size of slime - HEWGE, meh, cute BABBY SLIME
}
@ -2072,7 +2072,7 @@ void cProtocol125::WriteMobMetadata(const cMonster & a_Mob)
}
break;
}
case cMonster::mtHorse:
case mtHorse:
{
int Flags = 0;
if (((const cHorse &)a_Mob).IsTame())

View File

@ -2839,7 +2839,7 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
{
switch (a_Mob.GetMobType())
{
case cMonster::mtCreeper:
case mtCreeper:
{
WriteByte(0x10);
WriteByte(((const cCreeper &)a_Mob).IsBlowing() ? 1 : -1);
@ -2848,28 +2848,28 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
break;
}
case cMonster::mtBat:
case mtBat:
{
WriteByte(0x10);
WriteByte(((const cBat &)a_Mob).IsHanging() ? 1 : 0);
break;
}
case cMonster::mtPig:
case mtPig:
{
WriteByte(0x10);
WriteByte(((const cPig &)a_Mob).IsSaddled() ? 1 : 0);
break;
}
case cMonster::mtVillager:
case mtVillager:
{
WriteByte(0x50);
WriteInt(((const cVillager &)a_Mob).GetVilType());
break;
}
case cMonster::mtZombie:
case mtZombie:
{
WriteByte(0x0c);
WriteByte(((const cZombie &)a_Mob).IsBaby() ? 1 : 0);
@ -2880,14 +2880,14 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
break;
}
case cMonster::mtGhast:
case mtGhast:
{
WriteByte(0x10);
WriteByte(((const cGhast &)a_Mob).IsCharging());
break;
}
case cMonster::mtWolf:
case mtWolf:
{
const cWolf & Wolf = (const cWolf &)a_Mob;
Byte WolfStatus = 0;
@ -2915,7 +2915,7 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
break;
}
case cMonster::mtSheep:
case mtSheep:
{
WriteByte(0x10);
Byte SheepMetadata = 0;
@ -2928,7 +2928,7 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
break;
}
case cMonster::mtEnderman:
case mtEnderman:
{
WriteByte(0x10);
WriteByte((Byte)(((const cEnderman &)a_Mob).GetCarriedBlock()));
@ -2939,21 +2939,21 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
break;
}
case cMonster::mtSkeleton:
case mtSkeleton:
{
WriteByte(0x0d);
WriteByte(((const cSkeleton &)a_Mob).IsWither() ? 1 : 0);
break;
}
case cMonster::mtWitch:
case mtWitch:
{
WriteByte(0x15);
WriteByte(((const cWitch &)a_Mob).IsAngry() ? 1 : 0);
break;
}
case cMonster::mtWither:
case mtWither:
{
WriteByte(0x54); // Int at index 20
WriteInt(((const cWither &)a_Mob).GetWitherInvulnerableTicks());
@ -2962,21 +2962,21 @@ void cProtocol172::cPacketizer::WriteMobMetadata(const cMonster & a_Mob)
break;
}
case cMonster::mtSlime:
case mtSlime:
{
WriteByte(0x10);
WriteByte(((const cSlime &)a_Mob).GetSize());
break;
}
case cMonster::mtMagmaCube:
case mtMagmaCube:
{
WriteByte(0x10);
WriteByte(((const cMagmaCube &)a_Mob).GetSize());
break;
}
case cMonster::mtHorse:
case mtHorse:
{
const cHorse & Horse = (const cHorse &)a_Mob;
int Flags = 0;

View File

@ -1,6 +1,9 @@
#include "Globals.h"
#include "BlockEntities/ChestEntity.h"
typedef cItemCallback<cChestEntity> cChestCallback;
#include "IncrementalRedstoneSimulator.inc"
@ -13,7 +16,6 @@
#include "Blocks/BlockTripwireHook.h"
#include "Blocks/BlockDoor.h"
#include "Blocks/BlockPiston.h"
#include "BlockEntities/ChestEntity.h"
cRedstoneSimulator<cChunk, cWorld> * MakeIncrementalRedstoneSimulator(cWorld & a_World)
{

View File

@ -6,6 +6,8 @@
#include "RedstoneSimulator.h"
typedef cItemCallback<cEntity> cEntityCallback;
@ -1630,7 +1632,7 @@ void cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime,
}
default:
{
LOGD("Unimplemented pressure plate type %s in cRedstoneSimulator", ItemToFullString(a_MyType).c_str());
LOGD("Unimplemented pressure plate type %s in cRedstoneSimulator", ItemToFullString(cItem(a_MyType)).c_str());
break;
}
}
@ -1701,37 +1703,42 @@ void cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime,
}
}
template <class ChestType>
class cGetTrappedChestPlayers :
public cItemCallback<ChestType>
{
public:
cGetTrappedChestPlayers(void) :
m_NumberOfPlayers(0)
{
}
virtual ~cGetTrappedChestPlayers()
{
}
virtual bool Item(ChestType * a_Chest) override
{
ASSERT(a_Chest->GetBlockType() == E_BLOCK_TRAPPED_CHEST);
m_NumberOfPlayers = a_Chest->GetNumberOfPlayers();
return (m_NumberOfPlayers <= 0);
}
unsigned char GetPowerLevel(void) const
{
return std::min(m_NumberOfPlayers, MAX_POWER_LEVEL);
}
private:
int m_NumberOfPlayers;
};
template <class ChunkType, class WorldType, template <BLOCKTYPE block> class GetHandlerCompileTime, class ChestType>
void cIncrementalRedstoneSimulator<ChunkType, WorldType, GetHandlerCompileTime, ChestType>::HandleTrappedChest(int a_RelBlockX, int a_RelBlockY, int a_RelBlockZ)
{
class cGetTrappedChestPlayers :
public cChestCallback
{
public:
cGetTrappedChestPlayers(void) :
m_NumberOfPlayers(0)
{
}
virtual bool Item(ChestType * a_Chest) override
{
ASSERT(a_Chest->GetBlockType() == E_BLOCK_TRAPPED_CHEST);
m_NumberOfPlayers = a_Chest->GetNumberOfPlayers();
return (m_NumberOfPlayers <= 0);
}
unsigned char GetPowerLevel(void) const
{
return std::min(m_NumberOfPlayers, MAX_POWER_LEVEL);
}
private:
int m_NumberOfPlayers;
} GTCP;
cGetTrappedChestPlayers<ChestType> GTCP;
int BlockX = m_Chunk->GetPosX() * cChunkDef::Width + a_RelBlockX;
int BlockZ = m_Chunk->GetPosZ() * cChunkDef::Width + a_RelBlockZ;

View File

@ -7,6 +7,7 @@
#include "../Defines.h"
#include "../Entities/FallingBlock.h"
#include "../Chunk.h"
#include "inifile/iniFile.h"

View File

@ -1,6 +1,11 @@
#include "Globals.h"
#include "../World.h"
#include "../BlockID.h"
#include "../Defines.h"
#include "../Chunk.h"
#include "Simulator.inc"
#pragma clang diagnostic ignored "-Wweak-template-vtables"

View File

@ -2,7 +2,6 @@
#pragma once
#include "../Vector3.h"
#include "inifile/iniFile.h"

View File

@ -1,10 +1,6 @@
#include "Simulator.h"
#include "../World.h"
#include "../BlockID.h"
#include "../Defines.h"
#include "../Chunk.h"

View File

@ -791,8 +791,8 @@ void cWorld::InitialiseAndLoadMobSpawningValues(cIniFile & a_IniFile)
AStringVector SplitList = StringSplitAndTrim(AllMonsters, ",");
for (AStringVector::const_iterator itr = SplitList.begin(), end = SplitList.end(); itr != end; ++itr)
{
cMonster::eType ToAdd = cMonster::StringToMobType(*itr);
if (ToAdd != cMonster::mtInvalidType)
eMonsterType ToAdd = cMonster::StringToMobType(*itr);
if (ToAdd != mtInvalidType)
{
m_AllowedMobs.insert(ToAdd);
LOGD("Allowed mob: %s", itr->c_str());
@ -3126,7 +3126,7 @@ bool cWorld::IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ)
int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType)
int cWorld::SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType)
{
cMonster * Monster = NULL;

View File

@ -768,7 +768,7 @@ public:
bool IsBlockDirectlyWatered(int a_BlockX, int a_BlockY, int a_BlockZ); // tolua_export
/** Spawns a mob of the specified type. Returns the mob's EntityID if recognized and spawned, <0 otherwise */
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, cMonster::eType a_MonsterType) override; // tolua_export
virtual int SpawnMob(double a_PosX, double a_PosY, double a_PosZ, eMonsterType a_MonsterType) override; // tolua_export
int SpawnMobFinalize(cMonster* a_Monster);
/** Creates a projectile of the specified type. Returns the projectile's EntityID if successful, <0 otherwise
@ -923,7 +923,7 @@ private:
cChunkMap * m_ChunkMap;
bool m_bAnimals;
std::set<cMonster::eType> m_AllowedMobs;
std::set<eMonsterType> m_AllowedMobs;
eWeather m_Weather;
int m_WeatherInterval;

View File

@ -458,35 +458,35 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
const char * EntityClass = NULL;
switch (a_Monster->GetMobType())
{
case cMonster::mtBat: EntityClass = "Bat"; break;
case cMonster::mtBlaze: EntityClass = "Blaze"; break;
case cMonster::mtCaveSpider: EntityClass = "CaveSpider"; break;
case cMonster::mtChicken: EntityClass = "Chicken"; break;
case cMonster::mtCow: EntityClass = "Cow"; break;
case cMonster::mtCreeper: EntityClass = "Creeper"; break;
case cMonster::mtEnderDragon: EntityClass = "EnderDragon"; break;
case cMonster::mtEnderman: EntityClass = "Enderman"; break;
case cMonster::mtGhast: EntityClass = "Ghast"; break;
case cMonster::mtGiant: EntityClass = "Giant"; break;
case cMonster::mtHorse: EntityClass = "Horse"; break;
case cMonster::mtIronGolem: EntityClass = "VillagerGolem"; break;
case cMonster::mtMagmaCube: EntityClass = "LavaSlime"; break;
case cMonster::mtMooshroom: EntityClass = "MushroomCow"; break;
case cMonster::mtOcelot: EntityClass = "Ozelot"; break;
case cMonster::mtPig: EntityClass = "Pig"; break;
case cMonster::mtSheep: EntityClass = "Sheep"; break;
case cMonster::mtSilverfish: EntityClass = "Silverfish"; break;
case cMonster::mtSkeleton: EntityClass = "Skeleton"; break;
case cMonster::mtSlime: EntityClass = "Slime"; break;
case cMonster::mtSnowGolem: EntityClass = "SnowMan"; break;
case cMonster::mtSpider: EntityClass = "Spider"; break;
case cMonster::mtSquid: EntityClass = "Squid"; break;
case cMonster::mtVillager: EntityClass = "Villager"; break;
case cMonster::mtWitch: EntityClass = "Witch"; break;
case cMonster::mtWither: EntityClass = "WitherBoss"; break;
case cMonster::mtWolf: EntityClass = "Wolf"; break;
case cMonster::mtZombie: EntityClass = "Zombie"; break;
case cMonster::mtZombiePigman: EntityClass = "PigZombie"; break;
case mtBat: EntityClass = "Bat"; break;
case mtBlaze: EntityClass = "Blaze"; break;
case mtCaveSpider: EntityClass = "CaveSpider"; break;
case mtChicken: EntityClass = "Chicken"; break;
case mtCow: EntityClass = "Cow"; break;
case mtCreeper: EntityClass = "Creeper"; break;
case mtEnderDragon: EntityClass = "EnderDragon"; break;
case mtEnderman: EntityClass = "Enderman"; break;
case mtGhast: EntityClass = "Ghast"; break;
case mtGiant: EntityClass = "Giant"; break;
case mtHorse: EntityClass = "Horse"; break;
case mtIronGolem: EntityClass = "VillagerGolem"; break;
case mtMagmaCube: EntityClass = "LavaSlime"; break;
case mtMooshroom: EntityClass = "MushroomCow"; break;
case mtOcelot: EntityClass = "Ozelot"; break;
case mtPig: EntityClass = "Pig"; break;
case mtSheep: EntityClass = "Sheep"; break;
case mtSilverfish: EntityClass = "Silverfish"; break;
case mtSkeleton: EntityClass = "Skeleton"; break;
case mtSlime: EntityClass = "Slime"; break;
case mtSnowGolem: EntityClass = "SnowMan"; break;
case mtSpider: EntityClass = "Spider"; break;
case mtSquid: EntityClass = "Squid"; break;
case mtVillager: EntityClass = "Villager"; break;
case mtWitch: EntityClass = "Witch"; break;
case mtWither: EntityClass = "WitherBoss"; break;
case mtWolf: EntityClass = "Wolf"; break;
case mtZombie: EntityClass = "Zombie"; break;
case mtZombiePigman: EntityClass = "PigZombie"; break;
default:
{
ASSERT(!"Unhandled monster type");
@ -506,24 +506,24 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
m_Writer.AddByte("CanPickUpLoot", (char)a_Monster->CanPickUpLoot());
switch (a_Monster->GetMobType())
{
case cMonster::mtBat:
case mtBat:
{
m_Writer.AddByte("BatFlags", ((const cBat *)a_Monster)->IsHanging());
break;
}
case cMonster::mtCreeper:
case mtCreeper:
{
m_Writer.AddByte("powered", ((const cCreeper *)a_Monster)->IsCharged());
m_Writer.AddByte("ignited", ((const cCreeper *)a_Monster)->IsBlowing());
break;
}
case cMonster::mtEnderman:
case mtEnderman:
{
m_Writer.AddShort("carried", (Int16)((const cEnderman *)a_Monster)->GetCarriedBlock());
m_Writer.AddShort("carriedData", (Int16)((const cEnderman *)a_Monster)->GetCarriedMeta());
break;
}
case cMonster::mtHorse:
case mtHorse:
{
const cHorse & Horse = *((const cHorse *)a_Monster);
m_Writer.AddByte("ChestedHorse", Horse.IsChested());
@ -536,38 +536,38 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
m_Writer.AddByte("Saddle", Horse.IsSaddled());
break;
}
case cMonster::mtMagmaCube:
case mtMagmaCube:
{
m_Writer.AddInt("Size", ((const cMagmaCube *)a_Monster)->GetSize());
break;
}
case cMonster::mtSheep:
case mtSheep:
{
m_Writer.AddByte("Sheared", ((const cSheep *)a_Monster)->IsSheared());
m_Writer.AddByte("Color", ((const cSheep *)a_Monster)->GetFurColor());
break;
}
case cMonster::mtSlime:
case mtSlime:
{
m_Writer.AddInt("Size", ((const cSlime *)a_Monster)->GetSize());
break;
}
case cMonster::mtSkeleton:
case mtSkeleton:
{
m_Writer.AddByte("SkeletonType", (((const cSkeleton *)a_Monster)->IsWither() ? 1 : 0));
break;
}
case cMonster::mtVillager:
case mtVillager:
{
m_Writer.AddInt("Profession", ((const cVillager *)a_Monster)->GetVilType());
break;
}
case cMonster::mtWither:
case mtWither:
{
m_Writer.AddInt("Invul", ((const cWither *)a_Monster)->GetWitherInvulnerableTicks());
break;
}
case cMonster::mtWolf:
case mtWolf:
{
const cWolf & Wolf = *((cWolf *)a_Monster);
if (!Wolf.GetOwnerName().empty())
@ -583,7 +583,7 @@ void cNBTChunkSerializer::AddMonsterEntity(cMonster * a_Monster)
m_Writer.AddInt("CollarColor", Wolf.GetCollarColor());
break;
}
case cMonster::mtZombie:
case mtZombie:
{
m_Writer.AddByte("IsVillager", (((const cZombie *)a_Monster)->IsVillagerZombie() ? 1 : 0));
m_Writer.AddByte("IsBaby", (((const cZombie *)a_Monster)->IsBaby() ? 1 : 0));

View File

@ -5,3 +5,4 @@ enable_testing()
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
add_subdirectory(ChunkData)
add_subdirectory(Redstone)

View File

@ -0,0 +1,10 @@
cmake_minimum_required (VERSION 2.6)
enable_testing()
include_directories(${CMAKE_SOURCE_DIR}/src/)
add_definitions(-DTEST_GLOBALS=1)
add_executable(Redstone-creatable-exe creatable.cpp ../../src/BoundingBox.cpp)
add_test(NAME creatable-test COMMAND Redstone-creatable-exe)

View File

@ -0,0 +1,162 @@
#include "Globals.h"
class MockChest;
typedef cItemCallback<MockChest> cChestCallback;
AString ItemToFullString(const cItem & a_Item)
{
return "";
}
class cEntity
{
public:
const Vector3d & GetPosition (void) const { return m_pos;}
double GetWidth (void) const { return 0; }
double GetHeight (void) const { return 0; }
static const Vector3d m_pos;
};
const Vector3d cEntity::m_pos = Vector3d(0,0,0);
class cItem
{
public:
cItem(BLOCKTYPE val) {}
};
void cBlockInfo::Initialize(cBlockInfoArray & a_Info) {}
cBlockInfo::~cBlockInfo () {}
#include "Blocks/ChunkInterface.h"
bool cChunkInterface::ForEachChunkInRect(int a_MinChunkX, int a_MaxChunkX, int a_MinChunkZ, int a_MaxChunkZ, cChunkDataCallback & a_Callback)
{
return false;
}
bool cChunkInterface::WriteBlockArea(cBlockArea & a_Area, int a_MinBlockX, int a_MinBlockY, int a_MinBlockZ, int a_DataTypes)
{
return false;
}
#include "Simulator/Simulator.inc"
#include "Simulator/IncrementalRedstoneSimulator.inc"
class MockWorld;
class MockHandler
{
public:
static eBlockFace MetadataToDirection(NIBBLETYPE a_MetaData) { return BLOCK_FACE_NONE; }
static eBlockFace MetaDataToDirection(NIBBLETYPE a_MetaData) { return BLOCK_FACE_NONE; }
static eBlockFace BlockMetaDataToBlockFace(NIBBLETYPE a_MetaData) { return BLOCK_FACE_NONE; }
static NIBBLETYPE IsOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ) { return 0; }
static void ExtendPiston(int a_BlockX, int a_BlockY, int a_BlockZ, MockWorld * a_World) {}
static void RetractPiston(int a_BlockX, int a_BlockY, int a_BlockZ, MockWorld * a_World) {}
static void SetOpen(cChunkInterface & a_ChunkInterface, int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) {}
};
template<unsigned char val>
class MockHandlerFetcher
{
public:
typedef MockHandler type;
};
class MockWorld
{
public:
bool IsChunkLighted(int a_ChunkX, int a_ChunkZ) { return false; }
bool ForEachEntityInChunk(int a_ChunkX, int a_ChunkZ, cEntityCallback & a_Callback) { return false; }
void QueueLightChunk(int a_ChunkX, int a_ChunkZ, cChunkCoordCallback * a_Callback = NULL) {}
NIBBLETYPE GetBlockSkyLight (int a_BlockX, int a_BlockY, int a_BlockZ) { return 0; }
cPlayer * FindClosestPlayer(const Vector3d & a_Pos, float a_SightLimit, bool a_CheckLineOfSight = true) { return NULL; }
void WakeUpSimulators(int a_BlockX, int a_BlockY, int a_BlockZ) {}
void SpawnPrimedTNT(double a_X, double a_Y, double a_Z, int a_FuseTimeInSec = 80, double a_InitialVelocityCoeff = 1) {}
bool SetTrapdoorOpen(int a_BlockX, int a_BlockY, int a_BlockZ, bool a_Open) {return false; }
cChunkMap * GetChunkMap (void) { return NULL; }
};
class MockChunk
{
public:
cRedstoneSimulatorChunkData * GetRedstoneSimulatorData() { return NULL; }
bool IsRedstoneDirty() { return true; }
void SetIsRedstoneDirty(bool a_Param) {}
void GetBlockTypeMeta(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) {}
void SetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta, bool a_SendToClients = true) {}
void SetBlock( const Vector3i & a_RelBlockPos, BLOCKTYPE a_BlockType, NIBBLETYPE a_BlockMeta) {}
int GetPosX(void) const { return 0; }
int GetPosZ(void) const { return 0; }
MockChunk * GetRelNeighborChunkAdjustCoords(int & a_RelX, int & a_RelZ) const { return NULL; }
BLOCKTYPE GetBlock(int a_RelX, int a_RelY, int a_RelZ) const { return 0; }
BLOCKTYPE GetBlock(const Vector3i & a_RelCoords) const { return 0; }
NIBBLETYPE GetMeta(int a_RelX, int a_RelY, int a_RelZ) const { return 0; }
void SetMeta(int a_RelX, int a_RelY, int a_RelZ, NIBBLETYPE a_Meta) {}
bool UnboundedRelGetBlock(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType, NIBBLETYPE & a_BlockMeta) const { return false; }
bool UnboundedRelGetBlockType(int a_RelX, int a_RelY, int a_RelZ, BLOCKTYPE & a_BlockType) const { return false; }
MockChunk * GetNeighborChunk(int a_BlockX, int a_BlockZ) { return NULL; }
MockChunk * GetRelNeighborChunk(int a_RelX, int a_RelZ) { return NULL; }
bool IsValid(void) const { return false; }
NIBBLETYPE GetTimeAlteredLight(NIBBLETYPE a_Skylight) const { return 0; }
void BroadcastSoundParticleEffect(int a_EffectID, int a_SrcX, int a_SrcY, int a_SrcZ, int a_Data, const cClientHandle * a_Exclude = NULL) {}
void BroadcastSoundEffect (const AString & a_SoundName, double a_X, double a_Y, double a_Z, float a_Volume, float a_Pitch, const cClientHandle * a_Exclude = NULL) {}
bool DoWithRedstonePoweredEntityAt(int a_BlockX, int a_BlockY, int a_BlockZ, cRedstonePoweredCallback & a_Callback) { return false; }
template <class T>
bool DoWithChestAt(int a_BlockX, int a_BlockY, int a_BlockZ, T & a_Callback)
{
return false;
}
};
int main(int argc, char** argv)
{
class MockChest
{
public:
BLOCKTYPE GetBlockType(void) const { return 0; }
int GetNumberOfPlayers(void) const { return 0; }
};
MockWorld World;
cIncrementalRedstoneSimulator<MockChunk, MockWorld, MockHandlerFetcher, MockChest> Simulator(World);
return 0;
}