refactor: unglob std::wstring

This commit is contained in:
Tropical
2026-03-06 11:50:22 -06:00
parent 41db813a6d
commit cdc08700e4
581 changed files with 2156 additions and 2154 deletions

View File

@@ -14,25 +14,25 @@
#include "../../Headers/com.mojang.nbt.h"
#include "EntityIO.h"
std::unordered_map<wstring, entityCreateFn> *EntityIO::idCreateMap = new std::unordered_map<wstring, entityCreateFn>;
std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *EntityIO::classIdMap = new std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>;
std::unordered_map<std::wstring, entityCreateFn> *EntityIO::idCreateMap = new std::unordered_map<std::wstring, entityCreateFn>;
std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *EntityIO::classIdMap = new std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>;
std::unordered_map<int, entityCreateFn> *EntityIO::numCreateMap = new std::unordered_map<int, entityCreateFn>;
std::unordered_map<int, eINSTANCEOF> *EntityIO::numClassMap = new std::unordered_map<int, eINSTANCEOF>;
std::unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq> *EntityIO::classNumMap = new std::unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>;
std::unordered_map<wstring, int> *EntityIO::idNumMap = new std::unordered_map<wstring, int>;
std::unordered_map<std::wstring, int> *EntityIO::idNumMap = new std::unordered_map<std::wstring, int>;
std::unordered_map<int, EntityIO::SpawnableMobInfo *> EntityIO::idsSpawnableInCreative;
void EntityIO::setId(entityCreateFn createFn, eINSTANCEOF clas, const wstring &id, int idNum)
void EntityIO::setId(entityCreateFn createFn, eINSTANCEOF clas, const std::wstring &id, int idNum)
{
idCreateMap->insert( std::unordered_map<wstring, entityCreateFn>::value_type(id, createFn) );
classIdMap->insert( std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::value_type(clas,id ) );
idCreateMap->insert( std::unordered_map<std::wstring, entityCreateFn>::value_type(id, createFn) );
classIdMap->insert( std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::value_type(clas,id ) );
numCreateMap->insert( std::unordered_map<int, entityCreateFn>::value_type(idNum, createFn) );
numClassMap->insert( std::unordered_map<int, eINSTANCEOF>::value_type(idNum, clas) );
classNumMap->insert( std::unordered_map<eINSTANCEOF, int, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::value_type(clas, idNum) );
idNumMap->insert( std::unordered_map<wstring, int>::value_type(id, idNum) );
idNumMap->insert( std::unordered_map<std::wstring, int>::value_type(id, idNum) );
}
void EntityIO::setId(entityCreateFn createFn, eINSTANCEOF clas, const wstring &id, int idNum, eMinecraftColour color1, eMinecraftColour color2, int nameId)
void EntityIO::setId(entityCreateFn createFn, eINSTANCEOF clas, const std::wstring &id, int idNum, eMinecraftColour color1, eMinecraftColour color2, int nameId)
{
setId(createFn, clas, id, idNum);
@@ -98,7 +98,7 @@ void EntityIO::staticCtor()
setId(DragonFireball::create, eTYPE_DRAGON_FIREBALL, L"DragonFireball", 1000);
}
std::shared_ptr<Entity> EntityIO::newEntity(const wstring& id, Level *level)
std::shared_ptr<Entity> EntityIO::newEntity(const std::wstring& id, Level *level)
{
std::shared_ptr<Entity> entity;
@@ -181,16 +181,16 @@ int EntityIO::getId(std::shared_ptr<Entity> entity)
return (*it).second;
}
wstring EntityIO::getEncodeId(std::shared_ptr<Entity> entity)
std::wstring EntityIO::getEncodeId(std::shared_ptr<Entity> entity)
{
std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classIdMap->find( entity->GetType() );
std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator it = classIdMap->find( entity->GetType() );
if( it != classIdMap->end() )
return (*it).second;
else
return L"";
}
int EntityIO::getId(const wstring &encodeId)
int EntityIO::getId(const std::wstring &encodeId)
{
AUTO_VAR(it, idNumMap->find(encodeId));
if (it == idNumMap->end())
@@ -201,7 +201,7 @@ int EntityIO::getId(const wstring &encodeId)
return it->second;
}
wstring EntityIO::getEncodeId(int entityIoValue)
std::wstring EntityIO::getEncodeId(int entityIoValue)
{
//Class<? extends Entity> class1 = numClassMap.get(entityIoValue);
//if (class1 != null)
@@ -212,7 +212,7 @@ wstring EntityIO::getEncodeId(int entityIoValue)
AUTO_VAR(it, numClassMap->find(entityIoValue));
if(it != numClassMap->end() )
{
std::unordered_map<eINSTANCEOF, wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator classIdIt = classIdMap->find( it->second );
std::unordered_map<eINSTANCEOF, std::wstring, eINSTANCEOFKeyHash, eINSTANCEOFKeyEq>::iterator classIdIt = classIdMap->find( it->second );
if( classIdIt != classIdMap->end() )
return (*classIdIt).second;
else
@@ -235,7 +235,7 @@ int EntityIO::getNameId(int entityIoValue)
return id;
}
eINSTANCEOF EntityIO::getType(const wstring &idString)
eINSTANCEOF EntityIO::getType(const std::wstring &idString)
{
AUTO_VAR(it, numClassMap->find(getId(idString)));
if(it != numClassMap->end() )