refactor: unglob std::type_info

This commit is contained in:
Tropical 2026-03-06 12:14:56 -06:00 committed by JuiceyDev
parent 6c4c3a9c94
commit 31ba56f277
23 changed files with 36 additions and 36 deletions

View file

@ -10,7 +10,7 @@
#include "../../Headers/net.minecraft.world.phys.h" #include "../../Headers/net.minecraft.world.phys.h"
#include "AvoidPlayerGoal.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->mob = mob;
//this->avoidType = avoidType; //this->avoidType = avoidType;

View file

@ -15,10 +15,10 @@ private:
float maxDist; float maxDist;
Path *path; Path *path;
PathNavigation *pathNav; PathNavigation *pathNav;
const type_info& avoidType; const std::type_info& avoidType;
public: 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(); ~AvoidPlayerGoal();
virtual bool canUse(); virtual bool canUse();

View file

@ -2,12 +2,12 @@
#include "../../Headers/net.minecraft.world.entity.ai.control.h" #include "../../Headers/net.minecraft.world.entity.ai.control.h"
#include "InteractGoal.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); 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); setRequiredControlFlags(Control::LookControlFlag | Control::MoveControlFlag);
} }

View file

@ -5,6 +5,6 @@
class InteractGoal : public LookAtPlayerGoal class InteractGoal : public LookAtPlayerGoal
{ {
public: public:
InteractGoal(Mob *mob, const type_info& lookAtType, float lookDistance); InteractGoal(Mob *mob, const std::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, float probability);
}; };

View file

@ -5,7 +5,7 @@
#include "../../Headers/net.minecraft.world.phys.h" #include "../../Headers/net.minecraft.world.phys.h"
#include "LookAtPlayerGoal.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->mob = mob;
this->lookDistance = lookDistance; this->lookDistance = lookDistance;
@ -15,7 +15,7 @@ LookAtPlayerGoal::LookAtPlayerGoal(Mob *mob, const type_info& lookAtType, float
lookTime = 0; 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->mob = mob;
this->lookDistance = lookDistance; this->lookDistance = lookDistance;

View file

@ -17,11 +17,11 @@ private:
float lookDistance; float lookDistance;
int lookTime; int lookTime;
float probability; float probability;
const type_info& lookAtType; const std::type_info& lookAtType;
public: public:
LookAtPlayerGoal(Mob *mob, const type_info& lookAtType, float lookDistance); LookAtPlayerGoal(Mob *mob, const std::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, float probability);
virtual ~LookAtPlayerGoal() {} virtual ~LookAtPlayerGoal() {}
virtual bool canUse(); virtual bool canUse();

View file

@ -19,7 +19,7 @@ bool NearestAttackableTargetGoal::DistComp::operator() (std::shared_ptr<Entity>
return true; 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->targetType = targetType;
this->within = within; this->within = within;

View file

@ -18,17 +18,17 @@ public:
private: private:
weak_ptr<Mob> target; weak_ptr<Mob> target;
const type_info& targetType; const std::type_info& targetType;
int randomInterval; int randomInterval;
DistComp *distComp; DistComp *distComp;
public: 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); // 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 ~NearestAttackableTargetGoal();
virtual bool canUse(); virtual bool canUse();

View file

@ -2,7 +2,7 @@
#include "../../Headers/net.minecraft.world.entity.animal.h" #include "../../Headers/net.minecraft.world.entity.animal.h"
#include "NonTameRandomTargetGoal.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; this->tamableMob = mob;
} }

View file

@ -10,7 +10,7 @@ private:
TamableAnimal *tamableMob; // Owner of this goal TamableAnimal *tamableMob; // Owner of this goal
public: 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(); bool canUse();
}; };

View file

@ -70,7 +70,7 @@ private:
MobCategory(int maxVar, Material *spawnPositionMaterial, bool isFriendly, eINSTANCEOF eBase, bool isSingleType, int maxPerLevel); MobCategory(int maxVar, Material *spawnPositionMaterial, bool isFriendly, eINSTANCEOF eBase, bool isSingleType, int maxPerLevel);
public: public:
const type_info getBaseClass(); const std::type_info getBaseClass();
const eINSTANCEOF getEnumBaseClass(); // 4J added const eINSTANCEOF getEnumBaseClass(); // 4J added
int getMaxInstancesPerChunk(); int getMaxInstancesPerChunk();
int getMaxInstancesPerLevel(); // 4J added int getMaxInstancesPerLevel(); // 4J added

View file

@ -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)
{ {
} }

View file

@ -41,7 +41,7 @@ public:
void unload(bool unloadTileEntities) ; // 4J - added parameter void unload(bool unloadTileEntities) ; // 4J - added parameter
void markUnsaved(); void markUnsaved();
void getEntities(std::shared_ptr<Entity> except, AABB bb, std::vector<std::shared_ptr<Entity> > &es); 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(); int countEntities();
bool shouldSave(bool force); bool shouldSave(bool force);
void setBlocks(byteArray newBlocks, int sub); void setBlocks(byteArray newBlocks, int sub);

View file

@ -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 xc0 = Mth::floor((bb->x0 - 2) / 16);
int xc1 = Mth::floor((bb->x1 + 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; 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::vector<std::shared_ptr<Entity> > *entities = getEntitiesOfClass(baseClass, bb);
std::shared_ptr<Entity> closest = nullptr; 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); return savedDataStorage->get(clazz, id);
} }

View file

@ -419,8 +419,8 @@ public:
bool isClientSide; bool isClientSide;
std::vector<std::shared_ptr<Entity> > *getEntities(std::shared_ptr<Entity> except, AABB *bb); 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::vector<std::shared_ptr<Entity> > *getEntitiesOfClass(const std::type_info& baseClass, AABB *bb);
std::shared_ptr<Entity> getClosestEntityOfClass(const type_info& baseClass, AABB *bb, std::shared_ptr<Entity> source); std::shared_ptr<Entity> getClosestEntityOfClass(const std::type_info& baseClass, AABB *bb, std::shared_ptr<Entity> source);
std::vector<std::shared_ptr<Entity> > getAllEntities(); std::vector<std::shared_ptr<Entity> > getAllEntities();
void tileEntityChanged(int x, int y, int z, std::shared_ptr<TileEntity> te); void tileEntityChanged(int x, int y, int z, std::shared_ptr<TileEntity> te);
// unsigned int countInstanceOf(BaseObject::Class *clas); // unsigned int countInstanceOf(BaseObject::Class *clas);
@ -477,7 +477,7 @@ public:
bool isRainingAt(int x, int y, int z); bool isRainingAt(int x, int y, int z);
bool isHumidAt(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); 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); int getFreeAuxValueFor(const std::wstring& id);
void levelEvent(int type, int x, int y, int z, int data); 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); void levelEvent(std::shared_ptr<Player> source, int type, int x, int y, int z, int data);

View file

@ -1602,7 +1602,7 @@ void LevelChunk::getEntities(std::shared_ptr<Entity> except, AABB *bb, std::vect
#endif #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 yc0 = Mth::floor((bb->y0 - 2) / 16);
int yc1 = Mth::floor((bb->y1 + 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); std::shared_ptr<Entity> e = *it; //entities->at(i);
bool isAssignableFrom = false; 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; } 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(Mob) ) { if( dynamic_pointer_cast<Mob>(e) != NULL ) isAssignableFrom = true; }
else if ( ec == typeid(Monster) ) { if( dynamic_pointer_cast<Monster>(e) != NULL ) isAssignableFrom = true; } else if ( ec == typeid(Monster) ) { if( dynamic_pointer_cast<Monster>(e) != NULL ) isAssignableFrom = true; }

View file

@ -204,7 +204,7 @@ public:
#endif #endif
virtual void markUnsaved(); virtual void markUnsaved();
virtual void getEntities(std::shared_ptr<Entity> except, AABB *bb, std::vector<std::shared_ptr<Entity> > &es); 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 int countEntities();
virtual bool shouldSave(bool force); 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 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

View file

@ -20,7 +20,7 @@ SavedDataStorage::SavedDataStorage(LevelStorage *levelStorage)
loadAuxValues(); 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 )); AUTO_VAR(it, cache.find( id ));
if (it != cache.end()) return (*it).second; if (it != cache.end()) return (*it).second;

View file

@ -19,7 +19,7 @@ private:
public: public:
SavedDataStorage(LevelStorage *); 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 set(const std::wstring& id, std::shared_ptr<SavedData> data);
void save(); void save();

View file

@ -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)
{ {
} }

View file

@ -33,7 +33,7 @@ public:
void unload(bool unloadTileEntities) ; // 4J - added parameter void unload(bool unloadTileEntities) ; // 4J - added parameter
void markUnsaved(); void markUnsaved();
void getEntities(std::shared_ptr<Entity> except, AABB bb, std::vector<std::shared_ptr<Entity> > &es); 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(); int countEntities();
bool shouldSave(bool force); bool shouldSave(bool force);
void setBlocks(byteArray newBlocks, int sub); void setBlocks(byteArray newBlocks, int sub);

View file

@ -175,7 +175,7 @@ std::vector<Packet::PacketStatistics *> Packet::renderableStats = std::vector<Pa
int Packet::renderPos = 0; int Packet::renderPos = 0;
// sendToAnyClient - true - send to anyone, false - Sends to one person per dimension per machine // 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 0
if (idToClassMap.count(id) > 0) throw new IllegalArgumentException(std::wstring(L"Duplicate packet id:") + _toString<int>(id)); if (idToClassMap.count(id) > 0) throw new IllegalArgumentException(std::wstring(L"Duplicate packet id:") + _toString<int>(id));

View file

@ -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 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 // 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: public:
const __int64 createTime; const __int64 createTime;