mirror of
https://github.com/4jcraft/4jcraft.git
synced 2026-05-11 20:17:13 +00:00
refactor: unglob std::type_info
This commit is contained in:
parent
0855e6ddf4
commit
2ed4b1fe9e
|
|
@ -10,7 +10,7 @@
|
|||
#include "../../Headers/net.minecraft.world.phys.h"
|
||||
#include "AvoidPlayerGoal.h"
|
||||
|
||||
AvoidPlayerGoal::AvoidPlayerGoal(PathfinderMob *mob, const type_info& avoidType, float maxDist, float walkSpeed, float sprintSpeed) : avoidType(avoidType)
|
||||
AvoidPlayerGoal::AvoidPlayerGoal(PathfinderMob *mob, const std::type_info& avoidType, float maxDist, float walkSpeed, float sprintSpeed) : avoidType(avoidType)
|
||||
{
|
||||
this->mob = mob;
|
||||
//this->avoidType = avoidType;
|
||||
|
|
|
|||
|
|
@ -15,10 +15,10 @@ private:
|
|||
float maxDist;
|
||||
Path *path;
|
||||
PathNavigation *pathNav;
|
||||
const type_info& avoidType;
|
||||
const std::type_info& avoidType;
|
||||
|
||||
public:
|
||||
AvoidPlayerGoal(PathfinderMob *mob, const type_info& avoidType, float maxDist, float walkSpeed, float sprintSpeed);
|
||||
AvoidPlayerGoal(PathfinderMob *mob, const std::type_info& avoidType, float maxDist, float walkSpeed, float sprintSpeed);
|
||||
~AvoidPlayerGoal();
|
||||
|
||||
virtual bool canUse();
|
||||
|
|
|
|||
|
|
@ -2,12 +2,12 @@
|
|||
#include "../../Headers/net.minecraft.world.entity.ai.control.h"
|
||||
#include "InteractGoal.h"
|
||||
|
||||
InteractGoal::InteractGoal(Mob *mob, const type_info& lookAtType, float lookDistance) : LookAtPlayerGoal(mob, lookAtType, lookDistance)
|
||||
InteractGoal::InteractGoal(Mob *mob, const std::type_info& lookAtType, float lookDistance) : LookAtPlayerGoal(mob, lookAtType, lookDistance)
|
||||
{
|
||||
setRequiredControlFlags(Control::LookControlFlag | Control::MoveControlFlag);
|
||||
}
|
||||
|
||||
InteractGoal::InteractGoal(Mob *mob, const type_info& lookAtType, float lookDistance, float probability) : LookAtPlayerGoal(mob, lookAtType, lookDistance, probability)
|
||||
InteractGoal::InteractGoal(Mob *mob, const std::type_info& lookAtType, float lookDistance, float probability) : LookAtPlayerGoal(mob, lookAtType, lookDistance, probability)
|
||||
{
|
||||
setRequiredControlFlags(Control::LookControlFlag | Control::MoveControlFlag);
|
||||
}
|
||||
|
|
@ -5,6 +5,6 @@
|
|||
class InteractGoal : public LookAtPlayerGoal
|
||||
{
|
||||
public:
|
||||
InteractGoal(Mob *mob, const type_info& lookAtType, float lookDistance);
|
||||
InteractGoal(Mob *mob, const type_info& lookAtType, float lookDistance, float probability);
|
||||
InteractGoal(Mob *mob, const std::type_info& lookAtType, float lookDistance);
|
||||
InteractGoal(Mob *mob, const std::type_info& lookAtType, float lookDistance, float probability);
|
||||
};
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
#include "../../Headers/net.minecraft.world.phys.h"
|
||||
#include "LookAtPlayerGoal.h"
|
||||
|
||||
LookAtPlayerGoal::LookAtPlayerGoal(Mob *mob, const type_info& lookAtType, float lookDistance) : lookAtType(lookAtType)
|
||||
LookAtPlayerGoal::LookAtPlayerGoal(Mob *mob, const std::type_info& lookAtType, float lookDistance) : lookAtType(lookAtType)
|
||||
{
|
||||
this->mob = mob;
|
||||
this->lookDistance = lookDistance;
|
||||
|
|
@ -15,7 +15,7 @@ LookAtPlayerGoal::LookAtPlayerGoal(Mob *mob, const type_info& lookAtType, float
|
|||
lookTime = 0;
|
||||
}
|
||||
|
||||
LookAtPlayerGoal::LookAtPlayerGoal(Mob *mob, const type_info& lookAtType, float lookDistance, float probability) : lookAtType(lookAtType)
|
||||
LookAtPlayerGoal::LookAtPlayerGoal(Mob *mob, const std::type_info& lookAtType, float lookDistance, float probability) : lookAtType(lookAtType)
|
||||
{
|
||||
this->mob = mob;
|
||||
this->lookDistance = lookDistance;
|
||||
|
|
|
|||
|
|
@ -17,11 +17,11 @@ private:
|
|||
float lookDistance;
|
||||
int lookTime;
|
||||
float probability;
|
||||
const type_info& lookAtType;
|
||||
const std::type_info& lookAtType;
|
||||
|
||||
public:
|
||||
LookAtPlayerGoal(Mob *mob, const type_info& lookAtType, float lookDistance);
|
||||
LookAtPlayerGoal(Mob *mob, const type_info& lookAtType, float lookDistance, float probability);
|
||||
LookAtPlayerGoal(Mob *mob, const std::type_info& lookAtType, float lookDistance);
|
||||
LookAtPlayerGoal(Mob *mob, const std::type_info& lookAtType, float lookDistance, float probability);
|
||||
virtual ~LookAtPlayerGoal() {}
|
||||
|
||||
virtual bool canUse();
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ bool NearestAttackableTargetGoal::DistComp::operator() (std::shared_ptr<Entity>
|
|||
return true;
|
||||
}
|
||||
|
||||
NearestAttackableTargetGoal::NearestAttackableTargetGoal(Mob *mob, const type_info& targetType, float within, int randomInterval, bool mustSee, bool mustReach /*= false*/) : TargetGoal(mob, within, mustSee, mustReach), targetType(targetType)
|
||||
NearestAttackableTargetGoal::NearestAttackableTargetGoal(Mob *mob, const std::type_info& targetType, float within, int randomInterval, bool mustSee, bool mustReach /*= false*/) : TargetGoal(mob, within, mustSee, mustReach), targetType(targetType)
|
||||
{
|
||||
//this->targetType = targetType;
|
||||
this->within = within;
|
||||
|
|
|
|||
|
|
@ -18,17 +18,17 @@ public:
|
|||
|
||||
private:
|
||||
weak_ptr<Mob> target;
|
||||
const type_info& targetType;
|
||||
const std::type_info& targetType;
|
||||
int randomInterval;
|
||||
DistComp *distComp;
|
||||
|
||||
public:
|
||||
//public NearestAttackableTargetGoal(Mob mob, const type_info& targetType, float within, int randomInterval, bool mustSee)
|
||||
//public NearestAttackableTargetGoal(Mob mob, const std::type_info& targetType, float within, int randomInterval, bool mustSee)
|
||||
//{
|
||||
// this(mob, targetType, within, randomInterval, mustSee, false);
|
||||
//}
|
||||
|
||||
NearestAttackableTargetGoal(Mob *mob, const type_info& targetType, float within, int randomInterval, bool mustSee, bool mustReach = false);
|
||||
NearestAttackableTargetGoal(Mob *mob, const std::type_info& targetType, float within, int randomInterval, bool mustSee, bool mustReach = false);
|
||||
virtual ~NearestAttackableTargetGoal();
|
||||
|
||||
virtual bool canUse();
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
#include "../../Headers/net.minecraft.world.entity.animal.h"
|
||||
#include "NonTameRandomTargetGoal.h"
|
||||
|
||||
NonTameRandomTargetGoal::NonTameRandomTargetGoal(TamableAnimal *mob, const type_info& targetType, float within, int randomInterval, bool mustSee) : NearestAttackableTargetGoal(mob, targetType, within, randomInterval, mustSee)
|
||||
NonTameRandomTargetGoal::NonTameRandomTargetGoal(TamableAnimal *mob, const std::type_info& targetType, float within, int randomInterval, bool mustSee) : NearestAttackableTargetGoal(mob, targetType, within, randomInterval, mustSee)
|
||||
{
|
||||
this->tamableMob = mob;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ private:
|
|||
TamableAnimal *tamableMob; // Owner of this goal
|
||||
|
||||
public:
|
||||
NonTameRandomTargetGoal(TamableAnimal *mob, const type_info& targetType, float within, int randomInterval, bool mustSee);
|
||||
NonTameRandomTargetGoal(TamableAnimal *mob, const std::type_info& targetType, float within, int randomInterval, bool mustSee);
|
||||
|
||||
bool canUse();
|
||||
};
|
||||
|
|
@ -70,7 +70,7 @@ private:
|
|||
MobCategory(int maxVar, Material *spawnPositionMaterial, bool isFriendly, eINSTANCEOF eBase, bool isSingleType, int maxPerLevel);
|
||||
|
||||
public:
|
||||
const type_info getBaseClass();
|
||||
const std::type_info getBaseClass();
|
||||
const eINSTANCEOF getEnumBaseClass(); // 4J added
|
||||
int getMaxInstancesPerChunk();
|
||||
int getMaxInstancesPerLevel(); // 4J added
|
||||
|
|
|
|||
|
|
@ -148,7 +148,7 @@ void EmptyLevelChunk::getEntities(std::shared_ptr<Entity> except, AABB bb, std::
|
|||
{
|
||||
}
|
||||
|
||||
void EmptyLevelChunk::getEntitiesOfClass(const type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
void EmptyLevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public:
|
|||
void unload(bool unloadTileEntities) ; // 4J - added parameter
|
||||
void markUnsaved();
|
||||
void getEntities(std::shared_ptr<Entity> except, AABB bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
void getEntitiesOfClass(const type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
void getEntitiesOfClass(const std::type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
int countEntities();
|
||||
bool shouldSave(bool force);
|
||||
void setBlocks(byteArray newBlocks, int sub);
|
||||
|
|
|
|||
|
|
@ -3768,7 +3768,7 @@ std::vector<std::shared_ptr<Entity> > *Level::getEntities(std::shared_ptr<Entity
|
|||
}
|
||||
|
||||
|
||||
std::vector<std::shared_ptr<Entity> > *Level::getEntitiesOfClass(const type_info& baseClass, AABB *bb)
|
||||
std::vector<std::shared_ptr<Entity> > *Level::getEntitiesOfClass(const std::type_info& baseClass, AABB *bb)
|
||||
{
|
||||
int xc0 = Mth::floor((bb->x0 - 2) / 16);
|
||||
int xc1 = Mth::floor((bb->x1 + 2) / 16);
|
||||
|
|
@ -3805,7 +3805,7 @@ std::vector<std::shared_ptr<Entity> > *Level::getEntitiesOfClass(const type_info
|
|||
return es;
|
||||
}
|
||||
|
||||
std::shared_ptr<Entity> Level::getClosestEntityOfClass(const type_info& baseClass, AABB *bb, std::shared_ptr<Entity> source)
|
||||
std::shared_ptr<Entity> Level::getClosestEntityOfClass(const std::type_info& baseClass, AABB *bb, std::shared_ptr<Entity> source)
|
||||
{
|
||||
std::vector<std::shared_ptr<Entity> > *entities = getEntitiesOfClass(baseClass, bb);
|
||||
std::shared_ptr<Entity> closest = nullptr;
|
||||
|
|
@ -4512,7 +4512,7 @@ void Level::setSavedData(const std::wstring& id, std::shared_ptr<SavedData> data
|
|||
}
|
||||
|
||||
|
||||
std::shared_ptr<SavedData> Level::getSavedData(const type_info& clazz, const std::wstring& id)
|
||||
std::shared_ptr<SavedData> Level::getSavedData(const std::type_info& clazz, const std::wstring& id)
|
||||
{
|
||||
return savedDataStorage->get(clazz, id);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -419,8 +419,8 @@ public:
|
|||
bool isClientSide;
|
||||
|
||||
std::vector<std::shared_ptr<Entity> > *getEntities(std::shared_ptr<Entity> except, AABB *bb);
|
||||
std::vector<std::shared_ptr<Entity> > *getEntitiesOfClass(const type_info& baseClass, AABB *bb);
|
||||
std::shared_ptr<Entity> getClosestEntityOfClass(const type_info& baseClass, AABB *bb, std::shared_ptr<Entity> source);
|
||||
std::vector<std::shared_ptr<Entity> > *getEntitiesOfClass(const std::type_info& baseClass, AABB *bb);
|
||||
std::shared_ptr<Entity> getClosestEntityOfClass(const std::type_info& baseClass, AABB *bb, std::shared_ptr<Entity> source);
|
||||
std::vector<std::shared_ptr<Entity> > getAllEntities();
|
||||
void tileEntityChanged(int x, int y, int z, std::shared_ptr<TileEntity> te);
|
||||
// unsigned int countInstanceOf(BaseObject::Class *clas);
|
||||
|
|
@ -477,7 +477,7 @@ public:
|
|||
bool isRainingAt(int x, int y, int z);
|
||||
bool isHumidAt(int x, int y, int z);
|
||||
void setSavedData(const std::wstring& id, std::shared_ptr<SavedData> data);
|
||||
std::shared_ptr<SavedData> getSavedData(const type_info& clazz, const std::wstring& id);
|
||||
std::shared_ptr<SavedData> getSavedData(const std::type_info& clazz, const std::wstring& id);
|
||||
int getFreeAuxValueFor(const std::wstring& id);
|
||||
void levelEvent(int type, int x, int y, int z, int data);
|
||||
void levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data);
|
||||
|
|
|
|||
|
|
@ -1602,7 +1602,7 @@ void LevelChunk::getEntities(std::shared_ptr<Entity> except, AABB *bb, std::vect
|
|||
#endif
|
||||
}
|
||||
|
||||
void LevelChunk::getEntitiesOfClass(const type_info& ec, AABB *bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
void LevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB *bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
{
|
||||
int yc0 = Mth::floor((bb->y0 - 2) / 16);
|
||||
int yc1 = Mth::floor((bb->y1 + 2) / 16);
|
||||
|
|
@ -1638,7 +1638,7 @@ void LevelChunk::getEntitiesOfClass(const type_info& ec, AABB *bb, std::vector<s
|
|||
std::shared_ptr<Entity> e = *it; //entities->at(i);
|
||||
|
||||
bool isAssignableFrom = false;
|
||||
// Some special cases where the base class is a general type that our class may be derived from, otherwise do a direct comparison of type_info
|
||||
// Some special cases where the base class is a general type that our class may be derived from, otherwise do a direct comparison of std::type_info
|
||||
if( ec == typeid(Player) ) { if( dynamic_pointer_cast<Player>(e) != NULL ) isAssignableFrom = true; }
|
||||
else if ( ec == typeid(Mob) ) { if( dynamic_pointer_cast<Mob>(e) != NULL ) isAssignableFrom = true; }
|
||||
else if ( ec == typeid(Monster) ) { if( dynamic_pointer_cast<Monster>(e) != NULL ) isAssignableFrom = true; }
|
||||
|
|
|
|||
|
|
@ -204,7 +204,7 @@ public:
|
|||
#endif
|
||||
virtual void markUnsaved();
|
||||
virtual void getEntities(std::shared_ptr<Entity> except, AABB *bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
virtual void getEntitiesOfClass(const type_info& ec, AABB *bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
virtual void getEntitiesOfClass(const std::type_info& ec, AABB *bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
virtual int countEntities();
|
||||
virtual bool shouldSave(bool force);
|
||||
virtual int getBlocksAndData(byteArray *data, int x0, int y0, int z0, int x1, int y1, int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ SavedDataStorage::SavedDataStorage(LevelStorage *levelStorage)
|
|||
loadAuxValues();
|
||||
}
|
||||
|
||||
std::shared_ptr<SavedData> SavedDataStorage::get(const type_info& clazz, const std::wstring& id)
|
||||
std::shared_ptr<SavedData> SavedDataStorage::get(const std::type_info& clazz, const std::wstring& id)
|
||||
{
|
||||
AUTO_VAR(it, cache.find( id ));
|
||||
if (it != cache.end()) return (*it).second;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ private:
|
|||
|
||||
public:
|
||||
SavedDataStorage(LevelStorage *);
|
||||
std::shared_ptr<SavedData> get(const type_info& clazz, const std::wstring& id);
|
||||
std::shared_ptr<SavedData> get(const std::type_info& clazz, const std::wstring& id);
|
||||
void set(const std::wstring& id, std::shared_ptr<SavedData> data);
|
||||
void save();
|
||||
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ void WaterLevelChunk::getEntities(std::shared_ptr<Entity> except, AABB bb, std::
|
|||
{
|
||||
}
|
||||
|
||||
void WaterLevelChunk::getEntitiesOfClass(const type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
void WaterLevelChunk::getEntitiesOfClass(const std::type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public:
|
|||
void unload(bool unloadTileEntities) ; // 4J - added parameter
|
||||
void markUnsaved();
|
||||
void getEntities(std::shared_ptr<Entity> except, AABB bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
void getEntitiesOfClass(const type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
void getEntitiesOfClass(const std::type_info& ec, AABB bb, std::vector<std::shared_ptr<Entity> > &es);
|
||||
int countEntities();
|
||||
bool shouldSave(bool force);
|
||||
void setBlocks(byteArray newBlocks, int sub);
|
||||
|
|
|
|||
|
|
@ -175,7 +175,7 @@ std::vector<Packet::PacketStatistics *> Packet::renderableStats = std::vector<Pa
|
|||
int Packet::renderPos = 0;
|
||||
|
||||
// sendToAnyClient - true - send to anyone, false - Sends to one person per dimension per machine
|
||||
void Packet::map(int id, bool receiveOnClient, bool receiveOnServer, bool sendToAnyClient, bool renderStats, const type_info& clazz, packetCreateFn createFn)
|
||||
void Packet::map(int id, bool receiveOnClient, bool receiveOnServer, bool sendToAnyClient, bool renderStats, const std::type_info& clazz, packetCreateFn createFn)
|
||||
{
|
||||
#if 0
|
||||
if (idToClassMap.count(id) > 0) throw new IllegalArgumentException(std::wstring(L"Duplicate packet id:") + _toString<int>(id));
|
||||
|
|
|
|||
|
|
@ -55,7 +55,7 @@ public:
|
|||
|
||||
// 4J Stu - Added the sendToAnyClient param so we can limit some packets to be only sent to one player on a system
|
||||
// 4J Stu - Added renderStats param for use in debugging
|
||||
static void map(int id, bool receiveOnClient, bool receiveOnServer, bool sendToAnyClient, bool renderStats, const type_info& clazz, packetCreateFn );
|
||||
static void map(int id, bool receiveOnClient, bool receiveOnServer, bool sendToAnyClient, bool renderStats, const std::type_info& clazz, packetCreateFn );
|
||||
|
||||
public:
|
||||
const __int64 createTime;
|
||||
|
|
|
|||
Loading…
Reference in a new issue