1
0

Add setting to disable texture packs

This commit is contained in:
luk3yx 2022-11-12 10:20:32 +13:00
parent ecc472ab14
commit df9e57bf05
6 changed files with 23 additions and 0 deletions

View File

@ -1023,6 +1023,7 @@ Game::~Game()
delete draw_control;
extendedResourceCleanup();
setDisableTexturePacks(false);
g_settings->deregisterChangedCallback("doubletap_jump",
&settingChangedCallback, this);

View File

@ -47,6 +47,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
A cache from texture name to texture path
*/
MutexedMap<std::string, std::string> g_texturename_to_path_cache;
bool g_disable_texture_packs = false;
/*
Replaces the filename extension.
@ -2300,5 +2301,13 @@ video::ITexture *TextureSource::getShaderFlagsTexture(bool normalmap_present)
std::vector<std::string> getTextureDirs()
{
if (g_disable_texture_packs)
return {};
return fs::GetRecursiveDirs(g_settings->get("texture_path"));
}
void setDisableTexturePacks(const bool disable_texture_packs)
{
g_disable_texture_packs = disable_texture_packs;
}

View File

@ -322,3 +322,5 @@ struct TileSpec
};
std::vector<std::string> getTextureDirs();
void setDisableTexturePacks(const bool disable_texture_packs);

View File

@ -382,6 +382,7 @@ void set_default_settings()
// Server
settings->setDefault("compat_player_model", "character.b3d,3d_armor_character.b3d,skinsdb_3d_armor_character_5.b3d");
settings->setDefault("compat_send_original_model", "true");
settings->setDefault("disable_texture_packs", "false");
settings->setDefault("disable_escape_sequences", "false");
settings->setDefault("strip_color_codes", "false");
settings->setDefault("announce_mt", "true");

View File

@ -34,6 +34,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
#include "util/strfnd.h"
#include "client/clientevent.h"
#include "client/sound.h"
#include "client/tile.h"
#include "network/clientopcodes.h"
#include "network/connection.h"
#include "script/scripting_client.h"
@ -704,6 +705,7 @@ void Client::handleCommand_AnnounceMedia(NetworkPacket* pkt)
m_media_downloader->addFile(name, sha1_raw);
}
bool disable_texture_packs = false;
try {
std::string str;
@ -715,11 +717,16 @@ void Client::handleCommand_AnnounceMedia(NetworkPacket* pkt)
if (!baseurl.empty())
m_media_downloader->addRemoteServer(baseurl);
}
if (pkt->getRemainingBytes() >= 1)
*pkt >> disable_texture_packs;
}
catch(SerializationError& e) {
// not supported by server or turned off
}
setDisableTexturePacks(disable_texture_packs);
m_media_downloader->step(this);
}

View File

@ -2724,6 +2724,9 @@ void Server::sendMediaAnnouncement(session_t peer_id, const std::string &lang_co
}
pkt << g_settings->get("remote_media");
if (g_settings->getBool("disable_texture_packs"))
pkt << true;
Send(&pkt);
verbosestream << "Server: Announcing files to id(" << peer_id