Skip to content
Permalink
Browse files

Add /client cleardenied to clear list of denied texture pack URLs.

Since multiple times run into issues where someone accidentally denied a texture pack, and it's not obvious how to undo that, especially when you're using the web client.
  • Loading branch information
UnknownShadow200 committed Nov 30, 2019
1 parent ca72cf6 commit a14ff7cda2b388f6cad557c614475ee97caf31b0
Showing with 25 additions and 2 deletions.
  1. +14 −0 src/Chat.c
  2. +9 −2 src/TexturePack.c
  3. +2 −0 src/TexturePack.h
@@ -429,6 +429,19 @@ static struct ChatCommand ModelCommand = {
}
};

static void ClearDeniedCommand_Execute(const String* args, int argsCount) {
int count = TextureCache_ClearDenied();
Chat_Add1("Removed &e%i &fdenied texture pack URLs.", &count);
}

static struct ChatCommand ClearDeniedCommand = {
"ClearDenied", ClearDeniedCommand_Execute, false,
{
"&a/client cleardenied",
"&eClears the list of texture pack URLs you have denied",
}
};


/*########################################################################################################################*
*-------------------------------------------------------CuboidCommand-----------------------------------------------------*
@@ -589,6 +602,7 @@ static void Chat_Init(void) {
Commands_Register(&ModelCommand);
Commands_Register(&CuboidCommand);
Commands_Register(&TeleportCommand);
Commands_Register(&ClearDeniedCommand);

Chat_Logging = Options_GetBool(OPT_CHAT_LOGGING, true);
}
@@ -527,15 +527,22 @@ void TextureCache_Init(void) {
cc_bool TextureCache_HasAccepted(const String* url) { return EntryList_Find(&acceptedList, url) >= 0; }
cc_bool TextureCache_HasDenied(const String* url) { return EntryList_Find(&deniedList, url) >= 0; }

void TextureCache_Accept(const String* url) {
void TextureCache_Accept(const String* url) {
EntryList_Set(&acceptedList, url, &String_Empty);
EntryList_Save(&acceptedList);
}
void TextureCache_Deny(const String* url) {
void TextureCache_Deny(const String* url) {
EntryList_Set(&deniedList, url, &String_Empty);
EntryList_Save(&deniedList);
}

int TextureCache_ClearDenied(void) {
int count = deniedList.entries.count;
StringsBuffer_Clear(&deniedList.entries);
EntryList_Save(&deniedList);
return count;
}

CC_INLINE static void TextureCache_HashUrl(String* key, const String* url) {
String_AppendUInt32(key, Utils_CRC32((const cc_uint8*)url->buffer, url->length));
}
@@ -82,6 +82,8 @@ void TextureCache_Accept(const String* url);
/* Adds the given URL to list of denied URLs, then saves it. */
/* Denied URLs are never loaded. */
void TextureCache_Deny(const String* url);
/* Clears the list of denied URLs, returning number removed. */
int TextureCache_ClearDenied(void);

/* Returns whether the given URL has been cached. */
cc_bool TextureCache_Has(const String* url);

0 comments on commit a14ff7c

Please sign in to comment.
You can’t perform that action at this time.