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
+1 -1
View File
@@ -106,7 +106,7 @@ void Cube::render(Tesselator *t,float scale)
}
}
Cube *Cube::setId(const wstring &id)
Cube *Cube::setId(const std::wstring &id)
{
this->id = id;
return this;
+2 -2
View File
@@ -15,7 +15,7 @@ private:
public:
const float x0, y0, z0, x1, y1, z1;
wstring id;
std::wstring id;
public:
Cube(ModelPart *modelPart, int xTexOffs, int yTexOffs, float x0, float y0, float z0, int w, int h, int d, float g, int faceMask = 63, bool bFlipPoly3UVs = false); // 4J - added faceMask
@@ -25,5 +25,5 @@ private:
public:
void render(Tesselator *t,float scale);
Cube *setId(const wstring &id);
Cube *setId(const std::wstring &id);
};
@@ -31,12 +31,12 @@ void EntityRenderer::bindTexture(int resourceName)
entityRenderDispatcher->textures->bindTexture(resourceName);
}
void EntityRenderer::bindTexture(const wstring& resourceName)
void EntityRenderer::bindTexture(const std::wstring& resourceName)
{
entityRenderDispatcher->textures->bindTexture(resourceName);
}
bool EntityRenderer::bindTexture(const wstring& urlTexture, int backupTexture)
bool EntityRenderer::bindTexture(const std::wstring& urlTexture, int backupTexture)
{
Textures *t = entityRenderDispatcher->textures;
@@ -57,7 +57,7 @@ bool EntityRenderer::bindTexture(const wstring& urlTexture, int backupTexture)
}
}
bool EntityRenderer::bindTexture(const wstring& urlTexture, const wstring& backupTexture)
bool EntityRenderer::bindTexture(const std::wstring& urlTexture, const std::wstring& backupTexture)
{
Textures *t = entityRenderDispatcher->textures;
@@ -39,10 +39,10 @@ public:
virtual void render(std::shared_ptr<Entity> entity, double x, double y, double z, float rot, float a) = 0;
protected:
virtual void bindTexture(int resourceName); // 4J - added
virtual void bindTexture(const wstring& resourceName);
virtual void bindTexture(const std::wstring& resourceName);
virtual bool bindTexture(const wstring& urlTexture, int backupTexture); // 4J added
virtual bool bindTexture(const wstring& urlTexture, const wstring& backupTexture);
virtual bool bindTexture(const std::wstring& urlTexture, int backupTexture); // 4J added
virtual bool bindTexture(const std::wstring& urlTexture, const std::wstring& backupTexture);
private:
virtual void renderFlame(std::shared_ptr<Entity> e, double x, double y, double z, float a);
virtual void renderShadow(std::shared_ptr<Entity> e, double x, double y, double z, float pow, float a);
@@ -70,7 +70,7 @@ void HumanoidMobRenderer::additionalRendering(std::shared_ptr<Mob> mob, float a)
float s = 17 / 16.0f;
glScalef(s, -s, -s);
wstring extra = L"";
std::wstring extra = L"";
if (headGear->hasTag() && headGear->getTag()->contains(L"SkullOwner"))
{
extra = headGear->getTag()->getString(L"SkullOwner");
@@ -565,7 +565,7 @@ void ItemRenderer::renderGuiItemDecorations(Font *font, Textures *textures, std:
renderGuiItemDecorations(font, textures, item, x, y, L"", fAlpha);
}
void ItemRenderer::renderGuiItemDecorations(Font *font, Textures *textures, std::shared_ptr<ItemInstance> item, int x, int y, const wstring &countText, float fAlpha)
void ItemRenderer::renderGuiItemDecorations(Font *font, Textures *textures, std::shared_ptr<ItemInstance> item, int x, int y, const std::wstring &countText, float fAlpha)
{
if (item == NULL)
{
@@ -578,7 +578,7 @@ void ItemRenderer::renderGuiItemDecorations(Font *font, Textures *textures, std:
if (item->count > 1 || !countText.empty() || item->GetForceNumberDisplay())
{
MemSect(31);
wstring amount = countText;
std::wstring amount = countText;
if(amount.empty())
{
int count = item->count;
@@ -43,7 +43,7 @@ private:
public:
void renderGuiItemDecorations(Font *font, Textures *textures, std::shared_ptr<ItemInstance> item, int x, int y, float fAlpha = 1.0f);
void renderGuiItemDecorations(Font *font, Textures *textures, std::shared_ptr<ItemInstance> item, int x, int y, const wstring &countText, float fAlpha = 1.0f);
void renderGuiItemDecorations(Font *font, Textures *textures, std::shared_ptr<ItemInstance> item, int x, int y, const std::wstring &countText, float fAlpha = 1.0f);
private:
void fillRect(Tesselator *t, int x, int y, int w, int h, int c);
public:
@@ -330,7 +330,7 @@ void MobRenderer::renderName(std::shared_ptr<Mob> mob, double x, double y, doubl
}
// 4J Added parameter for color here so that we can colour players names
void MobRenderer::renderNameTag(std::shared_ptr<Mob> mob, const wstring& OriginalName, double x, double y, double z, int maxDist, int color /*= 0xffffffff*/)
void MobRenderer::renderNameTag(std::shared_ptr<Mob> mob, const std::wstring& OriginalName, double x, double y, double z, int maxDist, int color /*= 0xffffffff*/)
{
if ( app.GetGameSettings(eGameSetting_DisplayHUD)==0 )
@@ -399,7 +399,7 @@ void MobRenderer::renderNameTag(std::shared_ptr<Mob> mob, const wstring& Origina
std::shared_ptr<Player> player = dynamic_pointer_cast<Player>(mob);
if (player != NULL && app.isXuidDeadmau5( player->getXuid() ) ) offs = -10;
wstring playerName;
std::wstring playerName;
WCHAR wchName[2];
#if defined(__PS3__) || defined(__ORBIS__)
@@ -38,7 +38,7 @@ protected:
virtual int getOverlayColor(std::shared_ptr<Mob> mob, float br, float a);
virtual void scale(std::shared_ptr<Mob> mob, float a);
virtual void renderName(std::shared_ptr<Mob> mob, double x, double y, double z);
virtual void renderNameTag(std::shared_ptr<Mob> mob, const wstring& name, double x, double y, double z, int maxDist, int color = 0xff000000);
virtual void renderNameTag(std::shared_ptr<Mob> mob, const std::wstring& name, double x, double y, double z, int maxDist, int color = 0xff000000);
public:
// 4J Added
@@ -5,7 +5,7 @@ using namespace std;
class MobSpawnerRenderer : public TileEntityRenderer
{
private:
std::unordered_map<wstring, std::shared_ptr<Entity> > models;
std::unordered_map<std::wstring, std::shared_ptr<Entity> > models;
public:
virtual void render(std::shared_ptr<TileEntity> _spawner, double x, double y, double z, float a, bool setColor, float alpha=1.0f, bool useCompiled = true); // 4J added setColor param
};
@@ -27,7 +27,7 @@ const unsigned int PlayerRenderer::s_nametagColors[MINECRAFT_NET_MAX_PLAYERS] =
#endif
};
const wstring PlayerRenderer::MATERIAL_NAMES[5] = { L"cloth", L"chain", L"iron", L"diamond", L"gold" };
const std::wstring PlayerRenderer::MATERIAL_NAMES[5] = { L"cloth", L"chain", L"iron", L"diamond", L"gold" };
PlayerRenderer::PlayerRenderer() : MobRenderer( new HumanoidModel(0), 0.5f )
{
@@ -245,7 +245,7 @@ void PlayerRenderer::renderName(std::shared_ptr<Mob> _mob, double x, double y, d
if (dist < maxDist * maxDist)
{
// Truncate display names longer than 16 char
wstring msg = mob->getDisplayName();
std::wstring msg = mob->getDisplayName();
if (msg.length() > 16)
{
msg.resize(16);
@@ -351,7 +351,7 @@ void PlayerRenderer::additionalRendering(std::shared_ptr<Mob> _mob, float a)
float s = 17 / 16.0f;
glScalef(s, -s, -s);
wstring extra = L"";
std::wstring extra = L"";
if (headGear->hasTag() && headGear->getTag()->contains(L"SkullOwner"))
{
extra = headGear->getTag()->getString(L"SkullOwner");
@@ -20,7 +20,7 @@ public:
static unsigned int getNametagColour(int index);
private:
static const wstring MATERIAL_NAMES[5];
static const std::wstring MATERIAL_NAMES[5];
protected:
virtual int prepareArmor(std::shared_ptr<Mob> _player, int layer, float a);
@@ -195,7 +195,7 @@ void ProgressRenderer::setType(eProgressStringType eType)
LeaveCriticalSection( &ProgressRenderer::s_progress );
}
void ProgressRenderer::progressStage(wstring &wstrText)
void ProgressRenderer::progressStage(std::wstring &wstrText)
{
EnterCriticalSection( &ProgressRenderer::s_progress );
m_wstrText=wstrText;
@@ -203,10 +203,10 @@ void ProgressRenderer::progressStage(wstring &wstrText)
LeaveCriticalSection( &ProgressRenderer::s_progress );
}
wstring& ProgressRenderer::getProgressString(void)
std::wstring& ProgressRenderer::getProgressString(void)
{
EnterCriticalSection( &ProgressRenderer::s_progress );
wstring &temp=m_wstrText;
std::wstring &temp=m_wstrText;
LeaveCriticalSection( &ProgressRenderer::s_progress );
return temp;
}
@@ -15,7 +15,7 @@ public:
int getCurrentPercent();
int getCurrentTitle();
int getCurrentStatus();
wstring& getProgressString(void);
std::wstring& getProgressString(void);
ProgressRenderer::eProgressStringType getType();
private:
@@ -27,7 +27,7 @@ private:
int title;
__int64 lastTime;
bool noAbort;
wstring m_wstrText;
std::wstring m_wstrText;
eProgressStringType m_eType;
void setType(eProgressStringType eType);
@@ -38,6 +38,6 @@ public:
virtual void progressStartNoAbort(int string);
void _progressStart(int title);
virtual void progressStage(int status);
virtual void progressStage(wstring &wstrText);
virtual void progressStage(std::wstring &wstrText);
virtual void progressStagePercentage(int i);
};
@@ -60,7 +60,7 @@ void SignRenderer::render(std::shared_ptr<TileEntity> _sign, double x, double y,
glDepthMask(false);
int col = Minecraft::GetInstance()->getColourTable()->getColor(eMinecraftColour_Sign_Text);
wstring msg;
std::wstring msg;
// need to send the new data
// Get the current language setting from the console
DWORD dwLanguage = XGetLanguage( );
@@ -31,7 +31,7 @@ void SkullTileRenderer::init(TileEntityRenderDispatcher *tileEntityRenderDispatc
instance = this;
}
void SkullTileRenderer::renderSkull(float x, float y, float z, int face, float rot, int type, const wstring &extra)
void SkullTileRenderer::renderSkull(float x, float y, float z, int face, float rot, int type, const std::wstring &extra)
{
Model *model = skeletonModel;
@@ -47,7 +47,7 @@ void SkullTileRenderer::renderSkull(float x, float y, float z, int face, float r
case SkullTileEntity::TYPE_CHAR:
//if (!extra.empty())
//{
// wstring url = "http://skins.minecraft.net/MinecraftSkins/" + StringUtil.stripColor(extra) + ".png";
// std::wstring url = "http://skins.minecraft.net/MinecraftSkins/" + StringUtil.stripColor(extra) + ".png";
// if (!instance->tileEntityRenderDispatcher->textures->hasHttpTexture(url))
// {
@@ -20,5 +20,5 @@ public:
void render(std::shared_ptr<TileEntity> skull, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled = true);
void init(TileEntityRenderDispatcher *tileEntityRenderDispatcher);
void renderSkull(float x, float y, float z, int face, float rot, int type, const wstring &extra);
void renderSkull(float x, float y, float z, int face, float rot, int type, const std::wstring &extra);
};
@@ -8,7 +8,7 @@ void TileEntityRenderer::bindTexture(int resourceName)
if(t != NULL) t->bind(t->loadTexture(resourceName));
}
void TileEntityRenderer::bindTexture(const wstring& urlTexture, int backupTexture)
void TileEntityRenderer::bindTexture(const std::wstring& urlTexture, int backupTexture)
{
Textures *t = tileEntityRenderDispatcher->textures;
if(t != NULL) t->bind(t->loadHttpTexture(urlTexture, backupTexture));
@@ -13,8 +13,8 @@ public:
virtual void render(std::shared_ptr<TileEntity> entity, double x, double y, double z, float a, bool setColor, float alpha, bool useCompiled) = 0; // 4J added setColor param and alpha and useCompiled
virtual void onNewLevel(Level *level) {}
protected:
void bindTexture(int resourceName); // 4J - changed from wstring to int
void bindTexture(const wstring& urlTexture, int backupTexture); // 4J - changed from wstring to int
void bindTexture(int resourceName); // 4J - changed from std::wstring to int
void bindTexture(const std::wstring& urlTexture, int backupTexture); // 4J - changed from std::wstring to int
private:
Level *getLevel();
public:
+4 -4
View File
@@ -603,12 +603,12 @@ void LevelRenderer::renderEntities(Vec3 *cam, Culler *culler, float a)
mc->gameRenderer->turnOffLightLayer(a); // 4J - brought forward from 1.8.2
}
wstring LevelRenderer::gatherStats1()
std::wstring LevelRenderer::gatherStats1()
{
return L"C: " + _toString<int>(renderedChunks) + L"/" + _toString<int>(totalChunks) + L". F: " + _toString<int>(offscreenChunks) + L", O: " + _toString<int>(occludedChunks) + L", E: " + _toString<int>(emptyChunks);
}
wstring LevelRenderer::gatherStats2()
std::wstring LevelRenderer::gatherStats2()
{
return L"E: " + _toString<int>(renderedEntities) + L"/" + _toString<int>(totalEntities) + L". B: " + _toString<int>(culledEntities) + L", I: " + _toString<int>((totalEntities - culledEntities) - renderedEntities);
}
@@ -2560,7 +2560,7 @@ void LevelRenderer::cull(Culler *culler, float a)
}
}
void LevelRenderer::playStreamingMusic(const wstring& name, int x, int y, int z)
void LevelRenderer::playStreamingMusic(const std::wstring& name, int x, int y, int z)
{
if (name != L"")
{
@@ -2603,7 +2603,7 @@ void LevelRenderer::playSound(std::shared_ptr<Entity> entity,int iSound, double
// 4J-PB - original function. I've changed to an enum instead of string compares
// 4J removed -
/*
void LevelRenderer::addParticle(const wstring& name, double x, double y, double z, double xa, double ya, double za)
void LevelRenderer::addParticle(const std::wstring& name, double x, double y, double z, double xa, double ya, double za)
{
if (mc == NULL || mc->cameraTargetPlayer == NULL || mc->particleEngine == NULL) return;
+3 -3
View File
@@ -68,8 +68,8 @@ public:
void AddDLCSkinsToMemTextures();
public:
void renderEntities(Vec3 *cam, Culler *culler, float a);
wstring gatherStats1();
wstring gatherStats2();
std::wstring gatherStats1();
std::wstring gatherStats2();
private:
void resortChunks(int xc, int yc, int zc);
public:
@@ -106,7 +106,7 @@ public:
bool m_bSPUCullStarted[4];
#endif // __PS3__
void cull(Culler *culler, float a);
void playStreamingMusic(const wstring& name, int x, int y, int z);
void playStreamingMusic(const std::wstring& name, int x, int y, int z);
void playSound(int iSound, double x, double y, double z, float volume, float pitch, float fSoundClipDist=16.0f);
void playSound(std::shared_ptr<Entity> entity,int iSound, double x, double y, double z, float volume, float pitch, float fSoundClipDist=16.0f);
void addParticle(ePARTICLE_TYPE eParticleType, double x, double y, double z, double xa, double ya, double za); // 4J added
+2 -2
View File
@@ -11,12 +11,12 @@ Model::Model()
texHeight=32;
}
void Model::setMapTex(wstring id, int x, int y)
void Model::setMapTex(std::wstring id, int x, int y)
{
mappedTexOffs[id]=new TexOffs(x, y);
}
TexOffs *Model::getMapTex(wstring id)
TexOffs *Model::getMapTex(std::wstring id)
{
// 4J-PB - assuming there will always be this one
return mappedTexOffs[id];
+3 -3
View File
@@ -14,7 +14,7 @@ public:
bool riding;
vector<ModelPart *> cubes;
bool young;
std::unordered_map<wstring, TexOffs * > mappedTexOffs;
std::unordered_map<std::wstring, TexOffs * > mappedTexOffs;
int texWidth;
int texHeight;
@@ -25,8 +25,8 @@ public:
virtual ModelPart *getRandomCube(Random random) {return cubes.at(random.nextInt((int)cubes.size()));}
virtual ModelPart * AddOrRetrievePart(SKIN_BOX *pBox) { return NULL;}
void setMapTex(wstring id, int x, int y);
TexOffs *getMapTex(wstring id);
void setMapTex(std::wstring id, int x, int y);
TexOffs *getMapTex(std::wstring id);
protected:
float yHeadOffs;
@@ -23,7 +23,7 @@ ModelPart::ModelPart()
_init();
}
ModelPart::ModelPart(Model *model, const wstring& id)
ModelPart::ModelPart(Model *model, const std::wstring& id)
{
construct(model, id);
}
@@ -39,7 +39,7 @@ ModelPart::ModelPart(Model *model, int xTexOffs, int yTexOffs)
}
void ModelPart::construct(Model *model, const wstring& id)
void ModelPart::construct(Model *model, const std::wstring& id)
{
_init();
this->model = model;
@@ -108,7 +108,7 @@ ModelPart *ModelPart::texOffs(int xTexOffs, int yTexOffs)
return this;
}
ModelPart *ModelPart::addBox(wstring id, float x0, float y0, float z0, int w, int h, int d)
ModelPart *ModelPart::addBox(std::wstring id, float x0, float y0, float z0, int w, int h, int d)
{
id = this->id + L"." + id;
TexOffs *offs = model->getMapTex(id);
@@ -22,7 +22,7 @@ public:
static const float RAD;
private:
wstring id;
std::wstring id;
int xTexOffs, yTexOffs;
boolean compiled;
int list;
@@ -31,12 +31,12 @@ private:
public:
void _init(); // 4J added
ModelPart();
ModelPart(Model *model, const wstring &id);
ModelPart(Model *model, const std::wstring &id);
ModelPart(Model *model);
ModelPart(Model *model, int xTexOffs, int yTexOffs);
// MGH - had to add these for PS3, as calling constructors from others was only introduced in c++11 - https://en.wikipedia.org/wiki/C++11#Object_construction_improvement
void construct(Model *model, const wstring &id);
void construct(Model *model, const std::wstring &id);
void construct(Model *model);
void construct(Model *model, int xTexOffs, int yTexOffs);
@@ -44,7 +44,7 @@ public:
ModelPart * retrieveChild(SKIN_BOX *pBox);
ModelPart *mirror();
ModelPart *texOffs(int xTexOffs, int yTexOffs);
ModelPart *addBox(wstring id, float x0, float y0, float z0, int w, int h, int d);
ModelPart *addBox(std::wstring id, float x0, float y0, float z0, int w, int h, int d);
ModelPart *addBox(float x0, float y0, float z0, int w, int h, int d);
ModelPart *addBoxWithMask(float x0, float y0, float z0, int w, int h, int d, int faceMask); // 4J added
void addBox(float x0, float y0, float z0, int w, int h, int d, float g);
@@ -240,7 +240,7 @@ bool Particle::isAttackable()
}
//@Override
wstring Particle::toString()
std::wstring Particle::toString()
{
return L"A particle"; //getClass()->getSimpleName() + ", Pos (" + x + "," + y + "," + z + "), RGBA (" + rCol + "," + gCol + "," + bCol + "," + alpha + "), Age " + age;
}
@@ -49,5 +49,5 @@ public:
virtual void setMiscTex(int slotIndex);
virtual void setNextMiscAnimTex();
virtual bool isAttackable();
virtual wstring toString();
virtual std::wstring toString();
};
@@ -205,7 +205,7 @@ void ParticleEngine::crack(int x, int y, int z, int face)
}
wstring ParticleEngine::countParticles()
std::wstring ParticleEngine::countParticles()
{
int l = level->dimension->id == 0 ? 0 : (level->dimension->id == -1 ? 1 : 2 );
return _toString<int>((int)(particles[l][0].size() + particles[l][1].size() + particles[l][2].size()));
@@ -40,5 +40,5 @@ public:
void setLevel(Level *level);
void destroy(int x, int y, int z, int tid, int data);
void crack(int x, int y, int z, int face);
wstring countParticles();
std::wstring countParticles();
};